Socket connection timeout


is there a way to set a timeout when opening
a connection with TSocket, in case the server is down?

Thank You,

Bertrand Roessli


in principle if you connect to a host/port and there is no server running you will get immediately the error:

root [0] TSocket s("macroot2", 1032)
SysError in <TUnixSystem::UnixTcpConnect>: connect (macroot2:1032) (Connection refused)

In case you want to know if the server is ready to receive your data you can use:


which has a time-out argument.

Cheers, Fons.

Thanks for the answer, may-be I was not precise enough. In my case the computer, where the server is supposed to run, is down. In that case TSocket just tries to connect for ever (as telnet does, may-be this is

Bertrand Roessli

Ah yes, you are rigth after some (but long) time I get an error message
SysError in TUnixSystem::UnixTcpConnect: connect ( (Connection timed out)


Bertrand Roessli