Re: "connect'" returns before server "accept"s



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
.



Relevant Pages

  • Re: socket questions
    ... tcplistener, which is the server side, right? ... multiple connections use the same socket so it isn't as easy as listening to ... one channel for a response. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: BBC TV 4 - Hawkwind: Do not panic
    ... Server processes actively have to tell the OS they want to listen to the network on port such-and-such. ... (i.e., not the normal server listening on socket 80), and you set up the ... Telnet server to listen on socket 80, surely it should all `just work' ...
    (uk.comp.sys.mac)
  • Re: accept 1000 or more incoming conection
    ... The listen function places a socket a state where it is listening for ... SOCKET s, ... Now i have developed a client that Makes 500 connection to a server at ...
    (comp.programming.threads)
  • Socket state went to CLOSE_WAIT, when firewall blocks the ports on server side
    ... I got two systems say, A & B. A is Server and B is Client, ie, A ... listens to B. the listening port is 14505. ... socket on B will be grace fully closed. ... socket on sys A will go to CLOSE_WAIT state and never ...
    (microsoft.public.win32.programmer.networks)
  • Re: a question about socket and arrays !
    ... > I am going to send packets to the server using lots of threads(one ... > same amount of socket threads and then use them to send back the ... or just one socket listening on all coming packets? ... connections, and accept them as the server sees fit. ...
    (comp.lang.java.help)