Message18142
This is also a problem under HP-UX 11.0 with Python 2.5
The socket connect_ex() will return errno 22 EINVAL instead of
the more appropriate 239 ECONNREFUSED when connecting to a
non-listening socket ... but only if a socket timeout is being
used.
A system call trace reveils a little more what is going on.
For the python code
import socket
s = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
s.settimeout(15.0)
res = s.connect_ex( ('127.0.0.1', 8099) ) # An unused port number
the system call sequence is as follows:
Calling socket.socket()
socket(AF_INET, SOCK_STREAM, 0) = 3
Calling s.settimeout(15.0)
fcntl(3, F_GETFL, 0) = 2
fcntl(3, F_SETFL, 65538) = 0
Calling s.connect_ex(...)
connect(3, 0x400b43f0, 16) = -1 -> ERR#245 EINPROGRESS
poll(0x7cff1914, 1, 15000) = 1
connect(3, 0x400b43f0, 16) = -1 -> ERR#22 EINVAL
If the call to settimeout is removed, then an ERR#239 ECONNREFUSED
is returned by the first connect() and no subsequent poll+connect
is attempted. With the timeout set, note that the poll() returns
immediately no timeout actually occurs.
Note that tracing the same code under Linux shows the exact same
set of system calls, but that the second connect() call returns
ECONNREFUSED instead.
So this appears to be a specific behavior of HP-UX (and
perhaps other Unixes).
Excerpted from the HP man pages for connect(2):
[EINVAL] The socket has already been shut down or
has a listen() active on it; addrlen is
a bad value; an attempt was made to
connect() an AF_UNIX socket to an NFS-
mounted (remote) name; the X.121 address
length is zero, negative, or greater
than 15 digits.
For datagram sockets, if addrlen is a
bad value, the peer address is no longer
maintained by the system.
[ECONNREFUSED] The attempt to connect was forcefully
rejected.
[EINPROGRESS] Nonblocking I/O is enabled using
O_NONBLOCK, O_NDELAY, or FIOSNBIO, and
the connection cannot be completed
immediately. This is not a failure.
Make the connect() call again a few
seconds later. Alternatively, wait for
completion by calling select() and
selecting for write.
|
|
Date |
User |
Action |
Args |
2007-08-23 14:16:47 | admin | link | issue805194 messages |
2007-08-23 14:16:47 | admin | create | |
|