Re: accept() hangs
Re: accept() hangs
- Subject: Re: accept() hangs
- From: "Justin C. Walker" <email@hidden>
- Date: Sun, 9 Oct 2005 16:22:25 -0700
On Oct 9, 2005, at 15:50 , Ken Baer wrote:
I am trying to set up communications between a server and a
client. My client calls connect(), and my server is getting an
Accept message
What is an "Accept message"?
and calls accept() with the SOCKET it got from the message callback.
Typically, the server side will do something akin to
s = socket();
listen(s);
s1 = accept(s);
now use 's1' for your networking enjoyment...
The accept will hang until there is an incoming connection request
that matches the 'listen()' request. Is this roughly what your code
does?
Then accept() hangs. On the client side, connect() returns 0 and
the program continues, even before accept() is called on the server
side.
The kernel accepts (i.e., sends a SYN/ACK) for any incoming SYN
packet for which it has a matching 'listen()'. This means that the
client will receive an indication that the connection request has
been granted, even though the actual server has not had a chance to
decide (accept() returns a fully connected socket). It (the server
program) can later decide to decline the request, at which point the
client will receive a RESET. Of course, this all assumes you are
using TCP, or a protocol that uses TCP. Also, forgive the pedantry;
it isn't clear how much of this you know already.
The socket values seem correct, but I don't understand the
behavior. If I run the client without the server, the connect()
fails as I would expect it to.
I don't understand why accept() would hang in this situation.
It may be clear to someone else, but I don't understand it. My only
thought is that there is something odd in your initial setup (as above).
Regards,
Justin
PS: FWIW, if you don't already have it, consider investing in W.
Richard Stevens' Unix Network Programming. V1 (2nd or 3rd ed - the
latter being written by others) deals with the BSD socket model, and
is a very good resource.
--
Justin C. Walker, Curmudgeon at Large
Institute for General Semantics
-----------
My wife 'n kids 'n dogs are gone,
I can't get Jesus on the phone,
But Ol' Milwaukee's Best is my best friend.
-----------
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden