funny socket behaviour

Vasisht Tadigotla vasisht at eden.rutgers.edu
Wed Aug 7 20:07:22 EDT 2002


Hi,

I've been using python to write client-server programs and I've run into
this type of behaviour which seems weird. I'll try to illustrate it with
some code.

> from sockets import *
> import select
> s = socket(AF_INET,SOCK_STREAM)
> s.setblocking(0)
> s.connect(('remote_server',21))

At this point an EINPROGRESS exception is thrown.
now i do a select on the socket

> select.select([],[s.fileno()],[s.fileno()],10)
 if select is successful, i do a read

> s.recv(1024)

so far so good.
now i try to connect to the socket again
> s.connnect(('remote_server',21))

On SunOS, IRIX and FreeBSD, an EISCONN exception is thrown, but on Linux
it allows me to connect again to the socket after a connection has been
established. Though I cannot read/write to the socket when I connect a
second time, I think It should not allow a second connect. Any idea why
this should be happening ?

TIA

vasisht

please CC as I'm not subscribed to the list.


---------------------------------------------------------------------
ce .sig n'est pas une .sig







More information about the Python-list mailing list