Interpretations

Answering questions that may arise related to the meaning of portions of an IEEE standard concerning specific applications.

IEEE Standards Interpretations for IEEE Std 1003.1™-2001 IEEE Standard for Information Technology - Portable Operating System Interface (POSIX®)

Copyright © 2006 by the Institute of Electrical and Electronics Engineers, Inc. 3 Park Avenue New York, New York 10016-5997 USA All Rights Reserved.

Interpretations are issued to explain and clarify the intent of a standard and do not constitute an alteration to the original standard. In addition, interpretations are not intended to supply consulting information. Permission is hereby granted to download and print one copy of this document. Individuals seeking permission to reproduce and/or distribute this document in its entirety or portions of this document must contact the IEEE Standards Department for the appropriate license. Use of the information contained in this document is at your own risk.

IEEE Standards Department Copyrights and Permissions 445 Hoes Lane, Piscataway, New Jersey 08855-1331, USA

Interpretation Request #35
Topic: connected socket definition Relevant Sections: XBD Definitions

The standard uses the term "connected" for sockets without defining what it means. For example, in the description of the sendmsg() EISCONN error: "A destination address was specified and the socket is already connected." it is unclear whether this applies only to connection-mode sockets for which a connection has been established, or also to connectionless-mode sockets for which a peer address has been set using connect(). On the one hand there is this statement on the connect() page: "If the initiating socket is not connection-mode, then connect() shall set the socket's peer address, and no connection is made. For SOCK_DGRAM sockets, the peer address identifies where all datagrams are sent on subsequent send() functions, and limits the remote sender for subsequent recv() functions." Since it says "no connection is made" and does not say anything about the socket now being considered "connected", this would seem to point towards such sockets not being "connected". There is also this description of the send() ENOTCONN error: "The socket is not connected or otherwise has not had the peer pre-specified."

The use of "otherwise" here implies that "is connected" and "has had the peer pre-specified" are different things. However, on the other hand there are some uses of "connected" elsewhere which suggest the opposite. E.g. in section 2.10.16 Use of Options: "SO_ERROR may be used to check for asynchronous errors on connected connectionless-mode sockets" There are other places which just add to the confusion, such as the sendto() EISCONN description: "A destination address was specified and the socket is already connected. This error may or may not be returned for connection mode sockets." This is in the "may error" part of the ERRORS section, so the second sentence seems to be completely redundant. What, if anything, the presence of an explicit note about connection-mode sockets implies about connectionless-mode sockets is anyone's guess. Then there is this statement on the send() page which could be taken either way: "The send() function shall send a message only when the socket is connected (including when the peer of a connectionless socket has been set via connect())." The need for the remark in parentheses to be present seems to imply that without it the word "connected" would not be considered to apply, but its use of "including" suggests the opposite.

Insert a new definition before "3.108 Connection": Connected Socket A connection-mode socket for which a connection has been established, or a connectionless-mode socket for which a peer address has been set. See also Sections 3.108, 3.109, 3.110 and 3.348 (on page 83). The following changes to XSH would also help to remove some of the confusion: page 223 line 7458 section connect Change: "The connect() function shall attempt to make a connection on a socket." to: "The connect() function shall attempt to make a connection on a connection-mode socket or to set or reset the peer address of a connectionless-mode socket." page 223 line 7471 section connect Append: "Note that despite no connection being made, the term `connected' is used to describe a connectionless-mode socket for which a peer address has been set." page 1295 line 40598 section send Change: "(including when the peer of a connectionless socket has been set via connect())." to: "If the socket is connectionless-mode, the message shall be sent to the pre-specified peer address." page 1296 line 40635 section send Change: "The socket is not connected or otherwise has not had the peer pre-specified." to: "The socket is not connected." page 1302 line 40853 section sendto Delete "This error may or may not be returned for connection mode sockets."

Interpretation Response
The standard is unclear on this issue, and no conformance distinction can be made between alternative implementations based on this. This is being referred to the sponsor.

Rationale for Interpretation
None.

Notes to the Editor (not part of this interpretation)
Insert a new definition before "3.108 Connection": Connected Socket A connection-mode socket for which a connection has been established, or a connectionless-mode socket for which a peer address has been set. See also Sections 3.108, 3.109, 3.110 and 3.348 (on page 83). Note cross volume changes to XSH page 223 line 7458 section connect Change: "The connect() function shall attempt to make a connection on a socket." to: "The connect() function shall attempt to make a connection on a connection-mode socket or to set or reset the peer address of a connectionless-mode socket." page 223 line 7471 section connect Append: "Note that despite no connection being made, the term `connected' is used to describe a connectionless-mode socket for which a peer address has been set." page 1295 line 40598 section send Change: "(including when the peer of a connectionless socket has been set via connect())." to: "If the socket is connectionless-mode, the message shall be sent to the pre-specified peer address." page 1296 line 40635 section send Change: "The socket is not connected or otherwise has not had the peer pre-specified." to: "The socket is not connected." page 1302 line 40853 section sendto Delete "This error may or may not be returned for connection mode sockets."