Skip to content

Commit

Permalink
Merge pull request #4995 from OlegHahm/conn_udp_doc_same_thread
Browse files Browse the repository at this point in the history
doc: add notes that UDP receive functions must be called from same thread
  • Loading branch information
OlegHahm committed Mar 8, 2016
2 parents 49a7368 + b61b8e9 commit 2c33e69
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sys/include/net/conn/udp.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ typedef struct conn_udp conn_udp_t;
* @param[in] family The family of @p addr (see @ref net_af).
* @param[in] port The local UDP port for @p conn.
*
* @todo With @ref net_gnrc @ref conn_udp_recvfrom needs to be called from the
* same thread as for this function. This is undesired behavior and
* will be fixed in upcoming versions of RIOT.
*
* @return 0 on success.
* @return any other negative number in case of an error. For portability implementations should
* draw inspiration of the errno values from the POSIX' bind() function specification.
Expand Down Expand Up @@ -93,6 +97,10 @@ int conn_udp_getlocaladdr(conn_udp_t *conn, void *addr, uint16_t *port);
*
* @note Function may block.
*
* @todo With @ref net_gnrc this function needs to be called from the same
* thread as @ref conn_udp_create. This is undesired behavior and will
* be fixed in upcoming versions of RIOT.
*
* @return The number of bytes received on success.
* @return 0, if no received data is available, but everything is in order.
* @return any other negative number in case of an error. For portability, implementations should
Expand Down
18 changes: 18 additions & 0 deletions sys/posix/include/sys/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,13 @@ int bind(int socket, const struct sockaddr *address,
* on the address family of the socket.
* @param[in] address_len Specifies the length of the sockaddr structure
* pointed to by the address argument.
* @post The socket will be implicitely bound to an addressed, if it is not already bound.
* According to
* http://pubs.opengroup.org/onlinepubs/009695399/functions/connect.html
* for a "socket [that] has not already been bound to a local address,
* connect() shall bind it to an address which, unless the socket's
* address family is AF_UNIX, is an unused local address."
*
* @return Upon successful completion, connect() shall return 0; otherwise,
* -1 shall be returned and errno set to indicate the error.
*/
Expand Down Expand Up @@ -398,6 +405,17 @@ ssize_t send(int socket, const void *buffer, size_t length, int flags);
* @param[in] address_len Specifies the length of the sockaddr structure pointed
* to by the @p address argument.
*
* @post The socket will implicitely be bound to the unspecified address and
* a random port, in case it is not already bound. Rationale: A client
* should not require to explicitly call bind() to receive packets,
* but is expected to receive replies sent to the ephemeral port that
* was selected as a source port by the UDP implementation.
*
* @todo For @ref net_gnrc any @ref recvfrom call that is called to receive
* an expected response to this send command, must be called from the
* same thread. This is undesired behavior and will be fixed in
* upcoming versions of RIOT.
*
* @return Upon successful completion, send() shall return the number of bytes
* sent. Otherwise, -1 shall be returned and errno set to indicate the
* error.
Expand Down

0 comments on commit 2c33e69

Please sign in to comment.