Re: Problem using sockets
- From: Logan Shaw <lshaw-usenet@xxxxxxxxxxxxx>
- Date: Sat, 29 Mar 2008 22:29:40 -0500
Rainer Temme wrote:
sam.barker0@xxxxxxxxx wrote:
In some cases I can bind the port ,but I cannot connect.And the
program hangs there till it times out.How can can I avoid this?
The connect call blocks until the connection is extablished or until
its clear that it has failed to connect. The only way around this
behaviour is to use the socket in nonblocking mode. In this case
connect() will return immediately with returncode -1 and errno set to
EINPROGRESS.
But you're still going to need a timeout. You send a packet to the
remote side, and it will reply back with a response eventually.
But how quickly? It depends on network latency, network congestion
(and dropout rates), and the load on the remote host. The only
thing a non-blocking connect() is going to get you is more control
over the timeout. Well, I guess it also gives you the ability
to try both connections simultaneously by doing two non-blocking
connect()s and then sharing one timeout for both of them.
- Logan
.
- References:
- Problem using sockets
- From: sam . barker0
- Re: Problem using sockets
- From: Rainer Temme
- Problem using sockets
- Prev by Date: Re: trap divide error on Linux x86_64
- Next by Date: xpm.h ?
- Previous by thread: Re: Problem using sockets
- Next by thread: Re: Problem using sockets
- Index(es):
Relevant Pages
|