Reducing the timeout on a TCP connection
Dan Nelson
dnelson at allantgroup.com
Tue Aug 1 21:21:49 UTC 2006
In the last episode (Aug 01), Bill Moran said:
> In response to "Ted Mittelstaedt" <tedm at toybox.placo.com>:
> > This is why the snmp protocol uses UDP, Bill.
> >
> > You need to use something other than TCP for
> > monitoring.
>
> Well ... if I'm monitoring a server that uses TCP (PostgreSQL) I
> can't rightly establish whether or not it's successfully accepting
> connections unless I used TCP as well.
What I do is ping the target server first, with a small (1s) timeout.
If the ping fails, I don't try the TCP socket. If the ping succeeds, I
know the TCP connection will either complete or fail immediately.
Another option is to do non-blocking connects to as many servers as you
have fds available, and select()/poll()/kqueue() for the results. that
way at least you're checking other machines while waiting for the few
dead ones.
--
Dan Nelson
dnelson at allantgroup.com
More information about the freebsd-questions
mailing list