ConnectionTimeout versus SocketTimeout

Question

Im having a problem with a library I am using, it might be the library or it might be me using it wrong!

Basically when I do this (Timeout in milliseconds)

_ignitedHttp.setConnectionTimeout(1);  // v short
_ignitedHttp.setSocketTimeout(60000);  // 60 seconds

No timeout exception is generated works ok, however, when I do this:

_ignitedHttp.setConnectionTimeout(60000);  // 60 seconds
_ignitedHttp.setSocketTimeout(1);          // v short

I get a Socket Exception.

So my question is why can I not simulate a Connection Exception? Am I misunderstanding the difference between a socket and a connection time-out? The library is here (not officially realsed yet).

Answer

A connection timeout occurs only upon starting the TCP connection. This usually happens if the remote machine does not answer. This means that the server has been shut down, you used the wrong IP/DNS name or the network connection to the server is down.

A socket timeout is dedicated to monitor the continuous incoming data flow. If the data flow is interrupted for the specified timeout the connection is regarded as stalled/broken. Of course this only works with connections where data is received all the time.

By setting socket timeout to 1 this would require that every millisecond new data is received (assuming that you read the data block wise and the block is large enough)!

If only the incoming stream stalls for more than a millisecond you are running into a timeout.

results matching ""

    No results matching ""