Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #50246
| From | Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: How to clean up socket connection to printer |
| Date | 2013-07-09 16:05 +0200 |
| Message-ID | <lthtaa-u52.ln1@satorlaser.homedns.org> (permalink) |
| References | <c124b305-e2de-4355-bd20-15d0f9a40b65@googlegroups.com> |
Am 09.07.2013 11:39, schrieb 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. Strange. Why does the remote terminate the connection? > 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? I'm assuming you are using TCP. Getting a "connection refused" rather means that there is no server process that is listening on that port. It sounds a bit as if the printer was kind-of rebooting itself, which first resets the existing connection and then, after a rebooting, opens the port again for connections. Question here: 1. Does the printer accept connections again after some time? 2. Does the printer accept connections if you close and re-open the Python interpreter? 3. Is there actually a limit to the number of concurrent connections? In other words, what happens when you try to create a second connection without closing the first? > When I get the "Connection rest by peer" error, I attempt to close > the port as follows : [...] This is useless, the connection is already closed at that point. Your description suggests that it is a remote problem. I still wouldn't rule out that it is somehow caused by your code though, but without seeing that, it's impossible to tell. Good luck! Uli
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to clean up socket connection to printer loial <jldunn2000@gmail.com> - 2013-07-09 02:39 -0700
Re: How to clean up socket connection to printer Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-07-09 16:05 +0200
Re: How to clean up socket connection to printer loial <jldunn2000@gmail.com> - 2013-07-11 02:28 -0700
Re: How to clean up socket connection to printer Chris Angelico <rosuav@gmail.com> - 2013-07-11 20:13 +1000
Re: How to clean up socket connection to printer loial <jldunn2000@gmail.com> - 2013-07-15 04:22 -0700
csiph-web