lvfrazao / dhcppython

Pure Python library for parsing and manipulating DHCP packets
Apache License 2.0
19 stars 14 forks source link

Sockets are not closed when DHCPClient object is deleted #14

Open osresearch opened 1 year ago

osresearch commented 1 year ago

The various sockets are not closed when the dhcppython.client.DHCPClient is deleted, which leads to future DCHPClient objects not being able to obtain leases since the replies are delivered to the older sockets instead. I added a __del__ method to the class that closes them and now I can create new client objects:

    def __del__(self):
        for sock in self.listening_sockets:
            sock.close()
        for sock in self.writing_sockets:
            sock.close()
        for sock in self.except_sockets:
            sock.close()