Re: timeout for "socket"?



ZB wrote:
If I use "-async", there will be a handle for a connection returned
immediately - therefore I'll have to test the connection different way,
for example using fileevent, like in your script.

But I've got a feeling, "async & after" gives me nothing more: just instead
of setting the timeout when testing the connection immediately (no "async"),
I'm testing the connection using "fileevent" (for example) - 2000 ms later,
but still not setting test duration. Just the testing process itself starts
2 seconds later.

I would to make it try to connect, say, 5 seconds - and not to test the
connection 5 seconds later. It's not the same.

In a normal blocking socket connection, there are two phases that can
block. The first is during the lookup of the IP address for the name
you supplied, and the second is during the actual connection forming.
The -async option allows you to return to processing your script after
the first phase; the socket will become writable (in a [fileevent]
sense) when the connection is made or fails. But the first phase can
still block (name resolution is *disgusting*; if only we could assume
that we were using DNS...) and the only way to avoid that is to supply
an IP address in the first place; Tcl parses those immediately.

So, to test whether a service is up properly, you need to do this:
1) create a socket with -async set using the numeric IP address of
the machine you're contacting
2) then set up the timeout with [after]
3) then set up a writable [fileevent]
4) now you either get a writable event or a timer event first; if
you get the writable event, you need to use [fconfigure -error] to see
if there was an error happened (IIRC)
5) you only have a successful check if you didn't timeout and didn't
get an error connecting.

Hope that explains better what's going on with this sort of checking.

Donal.
.



Relevant Pages

  • Re: OE6 does not connect with pop3 server
    ... Can we infer from this that you got a timeout on the EarthLink account ... My point about making an approximate timestamp is just to look at the ... E.g. as near as possible before the connection ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: Timout control with RPC/HTTP
    ... specifies the minimum connection timeout used by the ... client and RPC Proxy, in seconds. ... Microsoft CSS Online Newsgroup Support ...
    (microsoft.public.exchange.admin)
  • Re: Timout control with RPC/HTTP
    ... please also check the RPC web site connection timeout settings ... Maybe the idle timeout settings depend on here. ...
    (microsoft.public.exchange.admin)
  • Re: web serivce: client side timeout?
    ... client side but only from the server side. ... System.Net.Sockets.SocketException: A connection attempt failed ... asyncResult, Int32 timeout, Exception& exception) ... John Saunders | MVP - Windows Server System - Connected System ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Timout control with RPC/HTTP
    ... But it is a IDLE timeout period that I am looking to control. ... But when they are idel the connection status will say - " last updated ...." ... Where do I control the settings for outlook to reconnect to the server to see if the mailbox is in sync with the remote lcoal cache. ... Microsoft CSS Online Newsgroup Support ...
    (microsoft.public.exchange.admin)