socket programming
Jaime Wyant
programmer.py at gmail.com
Tue Jul 19 15:24:57 EDT 2005
It sounds really strange to connect to a server "several hundred"
times. If I had to guess, the server monitored all of the connects
coming from your IP address and eventually stopped accepting ANY
connections.
jw
On 7/19/05, Helge Aksdal <helge at aksdal.net> wrote:
> i've recently made my very first socket program in python,
> however i've stumbled upon a problem.
>
> this program connects to a server serveral hundred time while it's
> executed (it's not possible to let connection stay up, because the
> server closes it), and after a time my program dies with the error:
> "socket.error: (134, 'Transport endpoint is not connected')"
>
> if i then change to a console window, and telnet to this server it
> sends me to another one. That's probably why my program dies, how
> can i get my code to handle this?
>
> Trying xxx.xxx.xxx.xxx
> telnet: connect to address xxx.xxx.xxx.xxx: Connection refused
> Trying xxx.xxx.xxx.xxx
> Connected to xxxxxx.xxxxx.
> Escape character is '^]'.
>
> here is my current connection code:
>
> def connect(self, server, port):
> self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> self.sock.setblocking(0)
> self.sock.connect((server, port))
> (sread, swrite, serror) = select.select([], [self.sock], [], 10)
> if swrite.count(self.sock) > 0:
> i = self.sock.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
> if 0 == i:
> self.sock.setblocking(1)
>
> --
> Helge Aksdal
> --
> http://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list