netdev
[Top] [All Lists]

Re: TCP: sendmsg/recvmsg/ioctl(SIOCINQ/SIOCOUTQ)

To: "David S. Miller" <davem@xxxxxxxxxx>
Subject: Re: TCP: sendmsg/recvmsg/ioctl(SIOCINQ/SIOCOUTQ)
From: "James R. Leu" <jleu@xxxxxxxxxxxxxx>
Date: Thu, 11 Jan 2001 17:47:26 -0600
Cc: netdev@xxxxxxxxxxx
In-reply-to: <14942.15689.642046.345119@xxxxxxxxxxxxxxx>; from davem@xxxxxxxxxx on Thu, Jan 11, 2001 at 03:10:01PM -0800
Organization: none
References: <921FA59842C3D111BB2400A0C9498D0B9EB241@xxxxxxxxxxxxxxxxxxx> <20010111164231.C29379@xxxxxxxxxxxxx> <14942.15689.642046.345119@xxxxxxxxxxxxxxx>
Reply-to: jleu@xxxxxxxxxxxxxx
Sender: owner-netdev@xxxxxxxxxxx
Hello David,

On Thu, Jan 11, 2001 at 03:10:01PM -0800, David S. Miller wrote:
> 
> James R. Leu writes:
>  > It seems that TCPs recvmsg/sendmsg and ioctl for SIOCINQ/SIOCOUTQ do not
>  > check to make sure the socket is connected.
> 
> And what is the problem with that?
> 
> If the socket is in the process of connecting (SYN_SENT or SYN_RECV)
> then SIOCINQ/SIOCOUTQ will report zero.  If closed or closing, it will
> report zero since by definition all data is sent.  The only invalid
> case is LISTEN, and we flag this with -EINVAL.

This makes sense.  I interpreted the The man page for tcp(4) to say that
FIONREAD and TIOCOUTQ would leave errno equal to EPIPE if the socket was
closed.

> For sendmsg/recvmsg you _want_ the kernel to wait for the connection
> attempt to complete if we are in SYN_SENT or SYN_RECV.  If this is not
> what is happening (the socket is some other kind of "closed") you will
> get an EPIPE (and perhaps a SIGPIPE signal) back.  This is all done
> via wait_for_tcp_connect in net/ipv4/tcp.c

In the code I see how sendmsg/recvmsg end up returning -EPIPE if the local
side has been shutdown (sk->shutdown & SEND_SHUTDOWN).   What should I expect
if I close down the remote side of the socket?

Thanks,
Jim
-- 
James R. Leu

<Prev in Thread] Current Thread [Next in Thread>