[Top] [All Lists]

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

To: jleu@xxxxxxxxxxxxxx
Subject: Re: TCP: sendmsg/recvmsg/ioctl(SIOCINQ/SIOCOUTQ)
From: "David S. Miller" <davem@xxxxxxxxxx>
Date: Thu, 11 Jan 2001 15:10:01 -0800 (PST)
Cc: netdev@xxxxxxxxxxx
In-reply-to: <>
References: <> <>
Sender: owner-netdev@xxxxxxxxxxx
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.

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 short I see no problems in the current implementation, and I doubt
any other BSD socket interface implementation acts much differently.

David S. Miller

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