Skip to content

Commit cded250

Browse files
committed
implement is_open method
1 parent f53e3b5 commit cded250

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/models/interfaces/tcp_client_interface.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,17 @@ def __init__(self, ip_address, ip_port, rx_timeout=DEFAULT_TIMEOUT, rx_buffer_si
2626
self._socket = None
2727

2828
def is_open(self):
29-
return True
29+
return self._socket is not None
3030

3131
def open(self):
32+
# There is no specific way to open this interface
3233
pass
3334

3435
def send_command(self, command, expect_response, pre_response, post_response):
3536
response = b""
3637
try:
37-
self._socket = socket.create_connection((self._server_ip_address, self._server_port),
38-
self._rx_timeout)
38+
self._socket = socket.create_connection(
39+
(self._server_ip_address, self._server_port), self._rx_timeout)
3940
except (Exception, ):
4041
self.raise_connection_exception(f"{self._server_ip_address}:{self._server_port}")
4142

@@ -51,6 +52,7 @@ def send_command(self, command, expect_response, pre_response, post_response):
5152
def close(self):
5253
if self._socket is not None:
5354
self._socket.close()
55+
self._socket = None
5456

5557
@classmethod
5658
def get_settings_controls(cls):

0 commit comments

Comments
 (0)