Re: whereis the socket mailing list
- From: daggerquill@xxxxxxxxx (Jay Savage)
- Date: Thu, 9 Feb 2006 13:00:16 -0500
"Because it's up-side down".
"Why is that?"
"It makes replies harder to read."
"Why not?"
"Please don't top-post." - Sherm Pendley, Mac OS X Perl list
On 2/9/06, Jeff Pang <pangj@xxxxxxxxxxxxx> wrote:
ok,I'll give my question and hope get some answers from here,:-)
I have a pair of Client-Server Socket programs.When the client have finished writing the datas,it should call the 'close()' or 'shutdown()' to close the client's socket.And,when the server receive the EOF coming from client,it should call the 'close()' or 'shutdown()' to close the socket too.Then the established socket between client and server should be freed.
As we know,the close behavier under tcp socket is shown as below:
Client ---> FIN ---> Server
Client <--- ACK <--- Server
Client <--- FIN <--- Server
Server ---> ACK ---> Client
The question I want to know is,when the 'close()' call happened,if it should generate a 'FIN' and send it to another end?If it's true,then at the server end,when it receive the 'EOF' coming from client,it can delay for some time to call 'close()',so the 'FIN' should not be sent to client immediately,is it?
I think your arrows are confused down there at the bottom, but it's a
little more complicated than that. The packets sent after FIN aren't
smiple ACKs, they have different types depending on what sequence
number they have, and who's sending them. If memory serves, FIN from
the server generates a FIN_ACK from the server, which generates an
ACKPSH from the client...but don't quote me on that, it's been a long
time.
The real question here, though, is "why are you worrying about this?"
This is why standard libraries exist. People have put decads of work
into abstracting the socket layer; you don't need to reinvent the
wheel. C Programmers have the standard socket library Socket.h. In
Perl, we have the Socket (basically just a wrapper for Socket.h) and
user-friendly IO::Socket modules. Let Them worry about the connection
for you.
Just call close() or shutdown() and don't sewat the details. If you
really need to know what happens when you call close(), read the
source. The nitty gritty TCP sequencing and timing is a little bit
beyond the scope of a beginner's list.
HTH,
-- jay
--------------------------------------------------
This email and attachment(s): [ ] blogable; [ x ] ask first; [ ]
private and confidential
daggerquill [at] gmail [dot] com
http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org
values of β will give rise to dom!
- References:
- Re: whereis the socket mailing list
- From: Jeff Pang
- Re: whereis the socket mailing list
- Prev by Date: total numbers of numbers input , largest number and smallest number and average of numbers
- Next by Date: Re: total numbers of numbers input , largest number and smallest number and average of numbers
- Previous by thread: Re: whereis the socket mailing list
- Next by thread: Re: whereis the socket mailing list
- Index(es):
Relevant Pages
|