Date: Fri, 13 Nov 1998 10:50:01 -0800 (PST) From: Jacques Vidrine <n@nectar.com> To: freebsd-bugs@FreeBSD.ORG Subject: Re: kern/8629: accept(2) errno uses incorrect code Message-ID: <199811131850.KAA04721@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/8629; it has been noted by GNATS. From: Jacques Vidrine <n@nectar.com> To: freebsd-gnats-submit@freebsd.org, Peter.Mutsaers@mail.ing.nl Cc: Subject: Re: kern/8629: accept(2) errno uses incorrect code Date: Fri, 13 Nov 1998 12:41:23 -0600 [WS1995] Wright, Gary R. and Richard W. Stevens. TCP/IP Illustrated, Volume 2. Addison-Wesley Publishing Company, Inc., 1995. The man pages for several UNIX operating systems (at least BSD 4.4 Lite, FreeBSD 3.0, and SunOS 5.5.1]) indicate that if accept is called with a socket of type SOCK_DGRAM, that the error returned will be EOPNOTSUPP. However, studying the implementation of the accept system call in BSD 4.4 Lite and FreeBSD 3.0, and the implementation discussed in [WS1995], accept returns EINVAL when called with a socket of type SOCK_DGRAM. This is because accept returns EINVAL for any socket that has not had listen() called on it, as these code fragments show. #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ if ((so->so_options & SO_ACCEPTCONN) == 0) { splx(s); return (EINVAL); } In fact, listen returns EOPNOTSUPP when called with a socket of type SOCK_DGRAM. The accept(2) man page should be updated to reflect reality. --- accept.2 1998/01/11 17:07:20 1.5 +++ accept.2 1998/11/13 18:37:09 @@ -171,9 +171,9 @@ The system file table is full. .It Bq Er ENOTSOCK The descriptor references a file, not a socket. -.It Bq Er EOPNOTSUPP -The referenced socket is not of type -.Dv SOCK_STREAM . +.It Bq Er EINVAL +.Xr listen 2 +has not been called on the socket descriptor. .It Bq Er EFAULT The .Fa addr -- Jacques Vidrine / n@nectar.com / nectar@FreeBSD.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199811131850.KAA04721>