From SUSE man pages, I get the below details for socket connect options
If the initiating socket is connection-mode, then connect() shall attempt to establish a connection to the address specified by the address argument. If the connection cannot be established immediately and O_NONBLOCK is not set for the file descriptor for the socket, connect() shall block for up to an unspecified timeout interval until the connection is established. If the timeout interval expires before the connection is established, connect() shall fail and the connection attempt shall be aborted. If connect() is interrupted by a signal that is caught while blocked waiting to establish a connection, connect() shall fail and set errno to [EINTR], but the connection request shall not be aborted, and the connection shall be established asynchronously.
Question : Is the above contents valid for AIX OS (especially the connection time-out, timed wait ...etc)?Because I do not see it in AIX man pages (5.1 and 5.3)
I have a client socket whose attributes are
a. SO_RCVTIMEO ,SO_SNDTIMEO are set for 5 seconds.
b. AF_INET and SOCK_STREAM.
c. SO_LINGER with linger on and time is 5 seconds.
d. SO_REUSEADDR is set.
Note that the client socket is not O_NONBLOCK.
Question : Now since O_NONBLOCK is not set and SO_RCVTIMEO and SO_SNDTIMEO is set for 5 seconds, does it mean
a. connect in NON Blocking or Blocking?
b. If blocking, is it timed blocking or "infinite" time blocking?
c. If it is infinite, How do I establish a "connect" system call which is O_BLOCKING with timeout to t secs.
Sorry if the questions are be very naive.
Thanks in advance for your input.
All,
Was able to finally find the answers to my questions after a through search and scan.
I am posting it so that it helps others who may face the same problem.
Question : Is the above contents valid for AIX OS (especially the connection time-out, timed wait ...etc)?Because I do not see it in AIX man pages (5.1 and 5.3)
From lots of search and some help from AIX support engineer found out that the man pages confirm with POSIX standard and should be valid for both AIX and SUSE OS.
Thus it proves that connect system API (O_BLOCK) can block in case of rare scenarios for unspecified time-out interval
Question : Now since O_NONBLOCK is not set and SO_RCVTIMEO and SO_SNDTIMEO is set for 5 seconds, does it mean
a. connect in NON Blocking or Blocking?
b. If blocking, is it timed blocking or "infinite" time blocking?
c. If it is infinite, How do I establish a "connect" system call which is O_BLOCKING with timeout to t secs.
a.If O_NONBLOCK is specified for SO_RCVTIMEO and/or SO_SNDTIMEO, then it is applicable for only those API's, i.e recv and send API's respectively.
b. If connect API is used for blocking call, then yes, connect can block for unspecified amount of interval.
Below link proved to be an excellent guide to understanding socket programming internals.
"http://www.ibm.com/developerworks/aix/library/au-tcpsystemcalls/index.html"
Thanks all for chipping in some time for my question.