Commit f1dcd117 authored by Arjen van Elteren's avatar Arjen van Elteren Committed by ORD

for endpoint with port == 0, read the port and hostname from the crea… (#239)

* for endpoint with port == 0, read the port and hostname from the created server scoket

this sets the port number from the created socket, possibly this change could trickle up to the actual server in the endpoint name

* fix copy paste error
parent 9398d465
......@@ -95,6 +95,14 @@ class BinaryServer(object):
coro = self.loop.create_server(OPCUAProtocol, self.hostname, self.port)
self._server = self.loop.run_coro_and_wait(coro)
# get the port and the hostname from the created server socket
# only relevant for dynamic port asignment (when self.port == 0)
if self.port == 0 and len(self._server.sockets) == 1:
# will work for AF_INET and AF_INET6 socket names
# these are to only families supported by the create_server call
sockname = self._server.sockets[0].getsockname()
self.hostname = sockname[0]
self.port = sockname[1]
print('Listening on {}:{}'.format(self.hostname, self.port))
def stop(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment