Hi,
I have a programming running on linux ubuntu which tries to connect to a server port using TCP. Can you please tell me how can I find out that is timeout value for a client socket connecting to a server socket for ubuntu?
Thank you.
Hi,
I have a programming running on linux ubuntu which tries to connect to a server port using TCP. Can you please tell me how can I find out that is timeout value for a client socket connecting to a server socket for ubuntu?
Thank you.
I'd start by looking at the getsockopt(3)
man page (SO_RCVTIMEO). However I'm sure there's more to your question than that.
The best, portable solution is to use your own timeout to be sure you can rely on a known value :
1) before connect()
ing, set the client socket to be non-blocking. Use ioctl()
and the FIONBIO
flag or fcntl()
and O_NONBLOCK
flags. Under Win32, use ioctlsocket()
and FIONBIO
flag.
2) connect()
to the remote peer : if connect()
succeed, all right, you are connected.
3) However if connect()
returns -1 and set errno
to EINPROGRESS
(WSAEWOULDBLOCK
under Win32), just select()
the socket descriptor for writing with your own timeout.