mirror of
https://github.com/JoelBender/bacpypes
synced 2025-10-05 22:18:16 +08:00
add the close_socket() function requested in #107
This commit is contained in:
parent
6b93f606ee
commit
66c4eebf55
|
@ -503,6 +503,12 @@ class BIPSimpleApplication(ApplicationIOController, WhoIsIAmServices, ReadWriteP
|
||||||
# bind the BIP stack to the network, no network number
|
# bind the BIP stack to the network, no network number
|
||||||
self.nsap.bind(self.bip)
|
self.nsap.bind(self.bip)
|
||||||
|
|
||||||
|
def close_socket(self):
|
||||||
|
if _debug: BIPSimpleApplication._debug("close_socket")
|
||||||
|
|
||||||
|
# pass to the multiplexer, then down to the sockets
|
||||||
|
self.mux.close_socket()
|
||||||
|
|
||||||
bacpypes_debugging(BIPSimpleApplication)
|
bacpypes_debugging(BIPSimpleApplication)
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -550,6 +556,12 @@ class BIPForeignApplication(ApplicationIOController, WhoIsIAmServices, ReadWrite
|
||||||
# bind the NSAP to the stack, no network number
|
# bind the NSAP to the stack, no network number
|
||||||
self.nsap.bind(self.bip)
|
self.nsap.bind(self.bip)
|
||||||
|
|
||||||
|
def close_socket(self):
|
||||||
|
if _debug: BIPForeignApplication._debug("close_socket")
|
||||||
|
|
||||||
|
# pass to the multiplexer, then down to the sockets
|
||||||
|
self.mux.close_socket()
|
||||||
|
|
||||||
bacpypes_debugging(BIPForeignApplication)
|
bacpypes_debugging(BIPForeignApplication)
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -102,6 +102,14 @@ class UDPMultiplexer:
|
||||||
self.annexH = _MultiplexServer(self)
|
self.annexH = _MultiplexServer(self)
|
||||||
self.annexJ = _MultiplexServer(self)
|
self.annexJ = _MultiplexServer(self)
|
||||||
|
|
||||||
|
def close_socket(self):
|
||||||
|
if _debug: UDPMultiplexer._debug("close_socket")
|
||||||
|
|
||||||
|
# pass along the close to the director(s)
|
||||||
|
self.directPort.close_socket()
|
||||||
|
if self.broadcastPort:
|
||||||
|
self.broadcastPort.close_socket()
|
||||||
|
|
||||||
def indication(self, server, pdu):
|
def indication(self, server, pdu):
|
||||||
if _debug: UDPMultiplexer._debug("indication %r %r", server, pdu)
|
if _debug: UDPMultiplexer._debug("indication %r %r", server, pdu)
|
||||||
|
|
||||||
|
|
|
@ -248,6 +248,12 @@ class UDPDirector(asyncore.dispatcher, Server, ServiceAccessPoint):
|
||||||
# let the director handle the error
|
# let the director handle the error
|
||||||
self.handle_error(err)
|
self.handle_error(err)
|
||||||
|
|
||||||
|
def close_socket(self):
|
||||||
|
"""Close the socket."""
|
||||||
|
if _debug: UDPDirector._debug("close_socket")
|
||||||
|
|
||||||
|
self.socket.close()
|
||||||
|
|
||||||
def handle_close(self):
|
def handle_close(self):
|
||||||
"""Remove this from the monitor when it's closed."""
|
"""Remove this from the monitor when it's closed."""
|
||||||
if _debug: UDPDirector._debug("handle_close")
|
if _debug: UDPDirector._debug("handle_close")
|
||||||
|
|
|
@ -500,6 +500,12 @@ class BIPSimpleApplication(ApplicationIOController, WhoIsIAmServices, ReadWriteP
|
||||||
# bind the BIP stack to the network, no network number
|
# bind the BIP stack to the network, no network number
|
||||||
self.nsap.bind(self.bip)
|
self.nsap.bind(self.bip)
|
||||||
|
|
||||||
|
def close_socket(self):
|
||||||
|
if _debug: BIPSimpleApplication._debug("close_socket")
|
||||||
|
|
||||||
|
# pass to the multiplexer, then down to the sockets
|
||||||
|
self.mux.close_socket()
|
||||||
|
|
||||||
#
|
#
|
||||||
# BIPForeignApplication
|
# BIPForeignApplication
|
||||||
#
|
#
|
||||||
|
@ -546,6 +552,12 @@ class BIPForeignApplication(ApplicationIOController, WhoIsIAmServices, ReadWrite
|
||||||
# bind the NSAP to the stack, no network number
|
# bind the NSAP to the stack, no network number
|
||||||
self.nsap.bind(self.bip)
|
self.nsap.bind(self.bip)
|
||||||
|
|
||||||
|
def close_socket(self):
|
||||||
|
if _debug: BIPForeignApplication._debug("close_socket")
|
||||||
|
|
||||||
|
# pass to the multiplexer, then down to the sockets
|
||||||
|
self.mux.close_socket()
|
||||||
|
|
||||||
#
|
#
|
||||||
# BIPNetworkApplication
|
# BIPNetworkApplication
|
||||||
#
|
#
|
||||||
|
|
|
@ -103,6 +103,14 @@ class UDPMultiplexer:
|
||||||
self.annexH = _MultiplexServer(self)
|
self.annexH = _MultiplexServer(self)
|
||||||
self.annexJ = _MultiplexServer(self)
|
self.annexJ = _MultiplexServer(self)
|
||||||
|
|
||||||
|
def close_socket(self):
|
||||||
|
if _debug: UDPMultiplexer._debug("close_socket")
|
||||||
|
|
||||||
|
# pass along the close to the director(s)
|
||||||
|
self.directPort.close_socket()
|
||||||
|
if self.broadcastPort:
|
||||||
|
self.broadcastPort.close_socket()
|
||||||
|
|
||||||
def indication(self, server, pdu):
|
def indication(self, server, pdu):
|
||||||
if _debug: UDPMultiplexer._debug("indication %r %r", server, pdu)
|
if _debug: UDPMultiplexer._debug("indication %r %r", server, pdu)
|
||||||
|
|
||||||
|
|
|
@ -247,6 +247,12 @@ class UDPDirector(asyncore.dispatcher, Server, ServiceAccessPoint):
|
||||||
# let the director handle the error
|
# let the director handle the error
|
||||||
self.handle_error(err)
|
self.handle_error(err)
|
||||||
|
|
||||||
|
def close_socket(self):
|
||||||
|
"""Close the socket."""
|
||||||
|
if _debug: UDPDirector._debug("close_socket")
|
||||||
|
|
||||||
|
self.socket.close()
|
||||||
|
|
||||||
def handle_close(self):
|
def handle_close(self):
|
||||||
"""Remove this from the monitor when it's closed."""
|
"""Remove this from the monitor when it's closed."""
|
||||||
if _debug: UDPDirector._debug("handle_close")
|
if _debug: UDPDirector._debug("handle_close")
|
||||||
|
|
|
@ -500,6 +500,12 @@ class BIPSimpleApplication(ApplicationIOController, WhoIsIAmServices, ReadWriteP
|
||||||
# bind the BIP stack to the network, no network number
|
# bind the BIP stack to the network, no network number
|
||||||
self.nsap.bind(self.bip)
|
self.nsap.bind(self.bip)
|
||||||
|
|
||||||
|
def close_socket(self):
|
||||||
|
if _debug: BIPSimpleApplication._debug("close_socket")
|
||||||
|
|
||||||
|
# pass to the multiplexer, then down to the sockets
|
||||||
|
self.mux.close_socket()
|
||||||
|
|
||||||
#
|
#
|
||||||
# BIPForeignApplication
|
# BIPForeignApplication
|
||||||
#
|
#
|
||||||
|
@ -546,6 +552,12 @@ class BIPForeignApplication(ApplicationIOController, WhoIsIAmServices, ReadWrite
|
||||||
# bind the NSAP to the stack, no network number
|
# bind the NSAP to the stack, no network number
|
||||||
self.nsap.bind(self.bip)
|
self.nsap.bind(self.bip)
|
||||||
|
|
||||||
|
def close_socket(self):
|
||||||
|
if _debug: BIPForeignApplication._debug("close_socket")
|
||||||
|
|
||||||
|
# pass to the multiplexer, then down to the sockets
|
||||||
|
self.mux.close_socket()
|
||||||
|
|
||||||
#
|
#
|
||||||
# BIPNetworkApplication
|
# BIPNetworkApplication
|
||||||
#
|
#
|
||||||
|
|
|
@ -102,6 +102,14 @@ class UDPMultiplexer:
|
||||||
self.annexH = _MultiplexServer(self)
|
self.annexH = _MultiplexServer(self)
|
||||||
self.annexJ = _MultiplexServer(self)
|
self.annexJ = _MultiplexServer(self)
|
||||||
|
|
||||||
|
def close_socket(self):
|
||||||
|
if _debug: UDPMultiplexer._debug("close_socket")
|
||||||
|
|
||||||
|
# pass along the close to the director(s)
|
||||||
|
self.directPort.close_socket()
|
||||||
|
if self.broadcastPort:
|
||||||
|
self.broadcastPort.close_socket()
|
||||||
|
|
||||||
def indication(self, server, pdu):
|
def indication(self, server, pdu):
|
||||||
if _debug: UDPMultiplexer._debug("indication %r %r", server, pdu)
|
if _debug: UDPMultiplexer._debug("indication %r %r", server, pdu)
|
||||||
|
|
||||||
|
|
|
@ -247,6 +247,12 @@ class UDPDirector(asyncore.dispatcher, Server, ServiceAccessPoint):
|
||||||
# let the director handle the error
|
# let the director handle the error
|
||||||
self.handle_error(err)
|
self.handle_error(err)
|
||||||
|
|
||||||
|
def close_socket(self):
|
||||||
|
"""Close the socket."""
|
||||||
|
if _debug: UDPDirector._debug("close_socket")
|
||||||
|
|
||||||
|
self.socket.close()
|
||||||
|
|
||||||
def handle_close(self):
|
def handle_close(self):
|
||||||
"""Remove this from the monitor when it's closed."""
|
"""Remove this from the monitor when it's closed."""
|
||||||
if _debug: UDPDirector._debug("handle_close")
|
if _debug: UDPDirector._debug("handle_close")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user