Copyright © 2006 IEEE. All rights reserved.
Interpretation Number: 035
Topic: connected socket definition
Relevant Sections: XBD Definitions ------------------------------------------------------------------------
7 Defect Report concerning (number and title of International Standard or DIS final text, if applicable):
The Base Definitions Volume of IEEE Std 1003.1-2001
------------------------------------------------------------------------
8 Qualifier (e.g. error, omission, clarification required):
3. Clarification required
------------------------------------------------------------------------
9 References in document (e.g. page, clause, figure, and/or table numbers):
XBD page 50 3.108
XBDbug2.txt Enhancement Request Number 32
------------------------------------------------------------------------
10 Nature of defect (complete, concise explanation of the perceived problem):
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.
------------------------------------------------------------------------
11 Solution proposed by the submitter (optional):
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: -------------
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."
Back to IEEE Standards Interpretations for IEEE Std 1003.1-2001