You can't set a connection time out value from the client side, usually connection time outs or idle time limits are controlled from the server side where the server keeps track of the idle times for the connections and forces close those that exceed the limits. One way to avoid this is by setting the
KeepAlive[
^] SocketOption.
Now from the code you posted, IF you are getting the IOException that you have defined then your connection is actually failing and you need to look at the actual exception that is occurring and not throwing a custom one.
The only time out limits that you can set from the client side are for sending and receiving data.