Re: (Simple) problem with sockets

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Lee,
Sorry for that as your linux box is not so
intelligent.
Actually the reason is that although the other side
has called up a close on that socket but the tcp state
machine does'nt closes the connection till it receives
a fin from the other side, thus doing a close on the
client would only stop the other side from sending the
data but still data and fin can be recv on the other
side. (I exactly don;t remeber but i suppose i am
correct). Thus, the TCP state machine on your side
will  only stop accepting any data from the client.
although it can send a fin or data from your side.
Also, abstraction wise the fd which you are getting is
a index into a file descp. table of your server
process which in turn points to a global file table in
the kernel which in turn points to the BSD socket
interface structure. And much below this comes the
tcp, so in any way tcp does'nt inform the above layers
to remove the file descp. entry from your file table
because the other person has closed the connection.
That's why when u try to read data, you get a value
zero specifying an EOF. After checking this u can
close the fd which will in turn do the rest of the
cleaning. Also, there can be various cases in which
auto closing of fd on the server would be wrong when
the client has closed that fd.
I hope i made myself clear.

PS: I suppose we don't expect our linux boxes to be so
smart.

cheers
malhacker

--- Lee Chin <leechin@mail.com> wrote:
> Here is a slightly related question:
> When I get a file descriptor via an accept system
> call... lets say the
> remote client closes the connection pre-maturely.
> 
> Will that file descriptor be re-assigned by Linux
> BEFORE I call cose on it? 
> If so, that may be the problem I'm having.
> 
> Thanks
> Lee
> 
> ------Original Message------
> From: Mark Hahn <hahn@coffee.psychology.mcmaster.ca>
> To: Mal Hacker <malhacker@yahoo.com>
> Sent: April 23, 2001 2:35:01 PM GMT
> Subject: Re: (Simple) problem with sockets
> 
> 
> > probably there is a solution like, when u get a
> > fd then just call "dup" on that fd and get the
> newfd.
> 
> and notice that dup2 actually lets *you* choose the
> final fd;
> you don't even have to assume this
> "lowest-available" policy.
> 
> 
> ______________________________________________
> FREE Personalized Email at Mail.com
> Sign up at http://www.mail.com/?sr=signup
> -
> : send the line
> "unsubscribe linux-net" in
> the body of a message to majordomo@vger.kernel.org


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/
-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux