L
loial
I have a socket application that is connecting to a HP printer via port 9100.
Occassionally I get a "Connection reset by peer" error which I am trapping and exiting the script with an error message.
That works Ok, the issue I have is that the next time I run the script I get
"Connection refused" from the printer, which suggests that the printer still thinks the port is is busy, though nothing is printing. I suspect that in some way my socket connection has not been closed correctly?
When I get the "Connection rest by peer" error, I attempt to close the port as follows :
try:
sock.close()
del sock
except Exception, e:
pass
Is there anything else I should do in these circumstances to ensure that my socket connection is closed OK?
Occassionally I get a "Connection reset by peer" error which I am trapping and exiting the script with an error message.
That works Ok, the issue I have is that the next time I run the script I get
"Connection refused" from the printer, which suggests that the printer still thinks the port is is busy, though nothing is printing. I suspect that in some way my socket connection has not been closed correctly?
When I get the "Connection rest by peer" error, I attempt to close the port as follows :
try:
sock.close()
del sock
except Exception, e:
pass
Is there anything else I should do in these circumstances to ensure that my socket connection is closed OK?