Interpretations

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

IEEE Standards Interpretation for IEEE Std 1003.1™-2001 IEEE Standard 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 #73
Topic: XSH 2.10.6 Socket Types, connect and sendto Relevant Sections: XSH 2.10.6 Socket Types Page: 60 Line: 2499

The standard is unclear regarding the behaviour of sendto() and sendmsg() on a datagram socket for which connect() has previously been called, in the case where the implementation does not return the optional EISCONN error.

The connect() page says: "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 this only refers to send() and not to sendto(), and since the sendto() page clearly states: "If the socket is connectionless-mode, the message shall be sent to the address specified by dest_addr." this would seem to imply that an address pre-specified using connect() is ignored by sendto().

Similar arguments apply to sendmsg().

However, section 2.10.6 Socket Types states the following for the SOCK_DGRAM socket type: "An application may also pre-specify a peer address, in which case calls to output functions shall send to the pre-specified peer." Since this says "output functions" it implies that send(), sendto() and sendmsg() are all treated the same

Here are two suggested ways to fix the problem, depending on whether the intention is for the pre-specified address to be used, or for the address given to sendto() and sendmsg() to override it. (A third alternative would be to mandate the EISCONN errors.)

Option A
On page 60 line 2499 change: "in which case calls to output functions shall send to the pre-specified peer" to: "in which case calls to output functions that do not specify a peer address shall send to the pre-specified peer"

On page 1297 line 40671 change: "If the socket is connectionless-mode, the message shall be sent to the address specified by msghdr." to: "If the socket is connectionless-mode, the message shall be sent to the address specified by msghdr if no pre-specified peer address has been set. If a peer address has been pre-specified, either the message shall be sent to the address specified in msghdr (overriding the pre-specified peer address), or the function shall return -1 and set errno to EISCONN."

On page 1300 line 40782 change: "If the socket is connectionless-mode, the message shall be sent to the address specified by dest_addr." to: "If the socket is connectionless-mode, the message shall be sent to the address specified by dest_addr if no pre-specified peer address has been set. If a peer address has been pre-specified, either the message shall be sent to the address specified by dest_addr (overriding the pre-specified peer address), or the function shall return -1 and set errno to EISCONN."

Option B
On page 60 line 2499 change: "in which case calls to output functions shall send to the pre-specified peer" to: "in which case calls to output functions shall send to the pre-specified peer, not to the peer address specified in the call (if any)"

On page 223 line 7469 change: "datagrams are sent on subsequent send() functions" to: "datagrams are sent by subsequent output functions (overriding any address specified to the output function)"

On page 1297 line 40671 change: "If the socket is connectionless-mode, the message shall be sent to the address specified by msghdr." to: "If the socket is connectionless-mode, the message shall be sent to the address specified by msghdr if no pre-specified peer address has been set. If a peer address has been pre-specified, either the message shall be sent to that address and the destination address in msghdr shall be ignored, or the function shall return -1 and set errno to EISCONN."

On page 1300 line 40782 change: "If the socket is connectionless-mode, the message shall be sent to the address specified by dest_addr." to: "If the socket is connectionless-mode, the message shall be sent to the address specified by dest_addr if no pre-specified peer address has been set. If a peer address has been pre-specified, either the message shall be sent to that address and dest_addr shall be ignored, or the function shall return -1 and set errno to EISCONN."

Interpretation Response #73
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.