Re: [gnet] connection with timeout



On 24 Jan 2003, Andreas Rottmann wrote:
> Axel Bock <news-and-lists the-me de> writes:
> > is anyone here who has implemented a connection request with a timeout?
> > So that the program tries to connect some host for - say - three
> > seconds, and if he has no connection after this time aborts and returns?
> > This is very useful for me cause I have to connect some firewalled hosts
> > who just drop the packets, so I have to wait for the tcp timers to go
> > out!
> >
> Use the acync connection function (there is an example, grep the
> sources) and a timer in your main loop.

Or call gnet_conn_connect() with no timeout and then call
gnet_conn_timeout(conn, 3000) to set the conn's timeout for 3 seconds.
When you get a connect, call gnet_conn_timeout(0) to turn off the timeout.

I removed the timeout argument to connect because timeout() made it
redundant for the most part.

David


-- 
      __          _    __ David Helder - dhelder umich edu
  ___/ /__ __  __(_)__/ / <http://www.eecs.umich.edu/~dhelder>
 / _  / _ `/ |/ / / _  /  DiaWebLog: <http://www.diaweblog.org>
 |_,_/|_,_/|___/_/|_,_/   Paper CD Case: <http://www.papercdcase.com>




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]