MCPcopy Create free account
hub / github.com/FreeOpcUa/python-opcua / connect_socket

Method connect_socket

opcua/client/ua_client.py:149–161  ·  view source on GitHub ↗

connect to server socket and start receiving thread

(self, host, port)

Source from the content-addressed store, hash-verified

147 return hdr
148
149 def connect_socket(self, host, port):
150 """
151 connect to server socket and start receiving thread
152 """
153 self.logger.info("opening connection")
154 # Create socket with timeout for initial connection
155 sock = socket.create_connection((host, port), timeout=self.timeout)
156 # set to blocking mode again
157 sock.settimeout(None)
158 # nodelay necessary to avoid packing in one frame, some servers do not like it
159 sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
160 self._socket = ua.utils.SocketWrapper(sock)
161 self.start()
162
163 def disconnect_socket(self):
164 self.logger.info("Request to close socket received")

Calls 1

startMethod · 0.95