From owner-freebsd-bugs Fri Nov 13 10:50:03 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA14131 for freebsd-bugs-outgoing; Fri, 13 Nov 1998 10:50:03 -0800 (PST) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id KAA14096 for ; Fri, 13 Nov 1998 10:49:57 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id KAA04721; Fri, 13 Nov 1998 10:50:01 -0800 (PST) Date: Fri, 13 Nov 1998 10:50:01 -0800 (PST) Message-Id: <199811131850.KAA04721@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.ORG From: Jacques Vidrine Subject: Re: kern/8629: accept(2) errno uses incorrect code Reply-To: Jacques Vidrine Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR kern/8629; it has been noted by GNATS. From: Jacques Vidrine 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