I am encountering some strange problems with the connect() routine on
IBM RS/6000 running AIX 3.2.
Before calling connect(), my program (client) calls bind() to bind the
socket to a specified port number and local host. The program will
connect to another specified port number on which another program
(server) is listening. What I need is the listening program will call
accept() and extract the port number bound to the connecting socket.
When I terminate the client while the server is still running, and then
restart the client, the connect() routine returns an EADDRINUSE error.
The funny thing is that bind() returns no error (I set the socket option
for SO_REUSEADDR). However, after a number of EADDRINUSE error, the
connect() routine will eventually be successful. On RS/6000, I have
tested that if the client is restarted 55 seconds after termination,
connect() is always successful. But is I restart the client at 50
seconds after termination, I will get EADDRINUSE at the connect()
Has anyone encountered the same problem or experienced similar situation
before? Would like to know what is the cause to this problem and how to
go about solving it. I suspect some kind of daemon for the network card
running at pre-defined time interval in releasing network resources
(ie., port numbers) maybe the reason but is not certain.
Thanks in advance to any reply.