Re: "connect'" returns before server "accept"s
- From: Joseph Dionne <jdionne@xxxxxxxxxxx>
- Date: Sat, 07 Jan 2006 03:19:21 GMT
chengiz@xxxxxxxxxxx wrote:
It seems even in a blocking socket world, "connect" can return immediately if the server has been set to "listen" but has not called "accept" yet. This is mentioned on the HPUX11 connect manpage, and I've seen the behaviour on Sun even though the manpage doesnt mention it. Is there a way to get "connect" to really block until accept() is called?
If this is not possible, perhaps there is a more specific solution for my actual problem: (1) A connection was established between client (connect) and server (bind + listen + accept). After communication, all sockets were closed. (2) If the client calls connect again on a new socket *before* the passive (listening) server socket of (1) closes, the connect returns 0 (success) immediately. Then the passive socket closes down, so the client ultimately crashes with an EPIPE in recv. (I cannot keep the passive socket alive or delay the next connect).
Any pointers and suggestions are appreciated. Thank you. Khan
I typically create sockets to non blocking connects, using poll() to wait for the socket to become write ready, or time out -- which can be INFINITE is you wish.
Joseph .
- Follow-Ups:
- Re: "connect'" returns before server "accept"s
- From: Michael Wojcik
- Re: "connect'" returns before server "accept"s
- References:
- "connect'" returns before server "accept"s
- From: chengiz
- "connect'" returns before server "accept"s
- Prev by Date: Re: TCP/UNIX Question
- Next by Date: Re: Valgrind false alarm?
- Previous by thread: "connect'" returns before server "accept"s
- Next by thread: Re: "connect'" returns before server "accept"s
- Index(es):
Relevant Pages
|