POSIX socket wrapper of RIOT's Sock API. More...

Detailed Description

POSIX socket wrapper of RIOT's Sock API.

See also
The Open Group Specifications Issue 7

Files

file  inet.h
 Definitions for internet operations.
 
file  in.h
 Main socket header.
 
file  socket.h
 Main socket header.
 

Data Structures

struct  in_addr
 IPv4 address structure type. More...
 
struct  in6_addr
 IPv6 address structure type. More...
 
struct  sockaddr_in
 IPv4 socket address type. More...
 
struct  sockaddr_in6
 IPv6 socket address type. More...
 
struct  ipv6_mreq
 IPv6 multicast request. More...
 
struct  sockaddr
 Used to define the socket address. More...
 
struct  sockaddr_storage
 Implementation based socket address table. More...
 

Macros

#define INADDRSZ   (4)
 Size in byte of an IPv4 address.
 
#define IN6ADDRSZ   (16)
 Size in byte of an IPv6 address.
 
#define INET_ADDRSTRLEN   (16)
 Length of the string form for IPv4.
 
#define INET6_ADDRSTRLEN   (46)
 Length of the string form for IPv6.
 
#define INADDR_ANY   ((in_addr_t)0x00000000)
 IPv4 local host address.
 
#define INADDR_BROADCAST   ((in_addr_t)0xffffffff)
 IPv4 broadcast address.
 
#define IN6ADDR_ANY_INIT   IPV6_ADDR_UNSPECIFIED
 IPv6 wildcard address.
 
#define IN6ADDR_LOOPBACK_INIT   IPV6_ADDR_LOOPBACK
 IPv6 loopback address.
 
#define SOCKET_POOL_SIZE   (4)
 Maximum number of sockets available on for creation with socket()
 
#define SOCKET_TCP_QUEUE_SIZE   (0)
 Maximum number of incoming TCP connections a listening socket can handle.
 
#define SOCKADDR_MAX_DATA_LEN   (26)
 Maximum data length for a socket address. More...
 
#define SOL_SOCKET   (-1)
 Options to be accessed at socket level, not protocol level.
 

Typedefs

typedef uint16_t in_port_t
 Internet port type. More...
 
typedef uint32_t in_addr_t
 IPv4 address type.
 
typedef unsigned short sa_family_t
 address family type
 

Functions

const char * inet_ntop (int af, const void *restrict src, char *restrict dst, socklen_t size)
 Converts an IP address to its string representation. More...
 
int inet_pton (int af, const char *src, void *dst)
 Converts an IP address string representation to a byte-represented IP address. More...
 
int accept (int socket, struct sockaddr *__restrict address, socklen_t *__restrict address_len)
 Accept a new connection on a socket. More...
 
int bind (int socket, const struct sockaddr *address, socklen_t address_len)
 Bind a name to a socket. More...
 
int connect (int socket, const struct sockaddr *address, socklen_t address_len)
 Connect a socket. More...
 
int getpeername (int socket, struct sockaddr *__restrict address, socklen_t *__restrict address_len)
 Get the name of the peer socket. More...
 
int getsockname (int socket, struct sockaddr *__restrict address, socklen_t *__restrict address_len)
 Get the socket name. More...
 
int listen (int socket, int backlog)
 Listen for socket connections and limit the queue of incoming connections. More...
 
ssize_t recvfrom (int socket, void *__restrict buffer, size_t length, int flags, struct sockaddr *__restrict address, socklen_t *__restrict address_len)
 Receive a message from a socket. More...
 
static ssize_t recv (int socket, void *buffer, size_t length, int flags)
 Receive a message from a connected socket. More...
 
ssize_t sendto (int socket, const void *buffer, size_t length, int flags, const struct sockaddr *address, socklen_t address_len)
 Send a message on a socket. More...
 
static ssize_t send (int socket, const void *buffer, size_t length, int flags)
 Send a message on a socket. More...
 
int socket (int domain, int type, int protocol)
 Create an endpoint for communication. More...
 

Variables

const struct in6_addr in6addr_any
 IPv6 socket address for the wildcard address.
 
const struct in6_addr in6addr_loopback
 IPv6 socket address for the loopback address.
 

IPv6 address macros

#define IN6_IS_ADDR_UNSPECIFIED(addr)   ((int)(ipv6_addr_is_unspecified((const ipv6_addr_t *)(addr))))
 Check if address is the unspecified address (::). More...
 
#define IN6_IS_ADDR_LOOPBACK(addr)   ((int)(ipv6_addr_is_loopback((const ipv6_addr_t *)(addr))))
 Check if address is the loopback address (::1). More...
 
#define IN6_IS_ADDR_MULTICAST(addr)   ((int)(ipv6_addr_is_multicast((const ipv6_addr_t *)(addr))))
 Check if address is a multicast address. More...
 
#define IN6_IS_ADDR_LINKLOCAL(addr)   ((int)(ipv6_addr_is_link_local((const ipv6_addr_t *)addr)))
 Check if address is a link-local address. More...
 
#define IN6_IS_ADDR_SITELOCAL(addr)   ((int)(ipv6_addr_is_site_local((const ipv6_addr_t *)addr)))
 Check if address is a site-local address. More...
 
#define IN6_IS_ADDR_V4MAPPED(addr)   ((int)(ipv6_addr_is_ipv4_mapped((const ipv6_addr_t *)addr)))
 Check if address is an IPv4 mapped address. More...
 
#define IN6_IS_ADDR_V4COMPAT(addr)   ((int)(ipv6_addr_is_ipv4_compat((const ipv6_addr_t *)addr)))
 Check if address is an IPv4-compatible address. More...
 
#define IN6_IS_ADDR_MC_NODELOCAL(addr)
 Check if address is a multicast node-local address. More...
 
#define IN6_IS_ADDR_MC_LINKLOCAL(addr)
 Check if address is a multicast link-local address. More...
 
#define IN6_IS_ADDR_MC_SITELOCAL(addr)
 Check if address is a multicast site-local address. More...
 
#define IN6_IS_ADDR_MC_ORGLOCAL(addr)
 Check if address is a multicast organization-local address. More...
 
#define IN6_IS_ADDR_MC_GLOBAL(addr)
 Check if address is a multicast global address. More...
 

Protocol numbers for option

#define IPPROTO_IP   (PROTNUM_IPV4)
 Internet Protocol version 4.
 
#define IPPROTO_IPV6   (PROTNUM_IPV6)
 Internet Protocol version 6.
 
#define IPPROTO_ICMP   (PROTNUM_ICMP)
 Internet Control Message Protocol.
 
#define IPPROTO_ICMPV6   (PROTNUM_ICMPV6)
 ICMP for IPv6.
 
#define IPPROTO_RAW   (PROTNUM_RESERVED)
 Raw IP packets protocol.
 
#define IPPROTO_TCP   (PROTNUM_TCP)
 Transmission control protocol.
 
#define IPPROTO_UDP   (PROTNUM_UDP)
 User datagram protocol.
 

Socket types

#define SOCK_DGRAM   (1)
 Datagram socket.
 
#define SOCK_RAW   (2)
 Raw socket.
 
#define SOCK_SEQPACKET   (3)
 Sequenced-packet socket.
 
#define SOCK_STREAM   (4)
 Stream socket.
 

Option names

Option names for getsockopt() and setsockopt()

#define SO_ACCEPTCONN   (0)
 Socket is accepting connections.
 
#define SO_BROADCAST   (1)
 Transmission of broadcast messages is supported.
 
#define SO_DEBUG   (2)
 Debugging information is being recorded.
 
#define SO_DONTROUTE   (3)
 Bypass normal routing.
 
#define SO_ERROR   (4)
 Socket error status.
 
#define SO_KEEPALIVE   (5)
 Connections are kept alive with periodic messages.
 
#define SO_LINGER   (6)
 Socket lingers on close.
 
#define SO_OOBINLINE   (7)
 Out-of-band data is transmitted in line.
 
#define SO_RCVBUF   (8)
 Receive buffer size.
 
#define SO_RCVLOWAT   (9)
 Receive "low water mark".
 
#define SO_RCVTIMEO   (10)
 Receive timeout.
 
#define SO_REUSEADDR   (11)
 Reuse of local addresses is supported.
 
#define SO_SNDBUF   (12)
 Send buffer size.
 
#define SO_SNDLOWAT   (13)
 Send "low water mark".
 
#define SO_SNDTIMEO   (14)
 Send timeout.
 
#define SO_TYPE   (15)
 Socket type.
 
static int getsockopt (int socket, int level, int option_name, void *option_value, socklen_t *option_len)
 
int setsockopt (int socket, int level, int option_name, const void *option_value, socklen_t option_len)
 

Macro Definition Documentation

◆ IN6_IS_ADDR_LINKLOCAL

#define IN6_IS_ADDR_LINKLOCAL (   addr)    ((int)(ipv6_addr_is_link_local((const ipv6_addr_t *)addr)))

Check if address is a link-local address.

Parameters
[in]addraddress of type const struct in6_addr *
Returns
0, when an address is not a link-local address.
any other value otherwise.

Definition at line 102 of file in.h.

◆ IN6_IS_ADDR_LOOPBACK

#define IN6_IS_ADDR_LOOPBACK (   addr)    ((int)(ipv6_addr_is_loopback((const ipv6_addr_t *)(addr))))

Check if address is the loopback address (::1).

Parameters
[in]addraddress of type const struct in6_addr *
Returns
0, when an address is not the loopback address.
any other value otherwise.

Definition at line 82 of file in.h.

◆ IN6_IS_ADDR_MC_GLOBAL

#define IN6_IS_ADDR_MC_GLOBAL (   addr)
Value:
(int)((addr->s6_addr[1] & 0x0f) == IPV6_ADDR_MCAST_SCP_GLOBAL))

Check if address is a multicast global address.

Parameters
[in]addraddress of type const struct in6_addr *
Returns
0, when an address is not a multicast global address.
any other value otherwise.

Definition at line 186 of file in.h.

◆ IN6_IS_ADDR_MC_LINKLOCAL

#define IN6_IS_ADDR_MC_LINKLOCAL (   addr)
Value:
(int)((addr->s6_addr[1] & 0x0f) == IPV6_ADDR_MCAST_SCP_LINK_LOCAL))

Check if address is a multicast link-local address.

Parameters
[in]addraddress of type const struct in6_addr *
Returns
0, when an address is not a multicast link-local address.
any other value otherwise.

Definition at line 153 of file in.h.

◆ IN6_IS_ADDR_MC_NODELOCAL

#define IN6_IS_ADDR_MC_NODELOCAL (   addr)
Value:
(int)((addr->s6_addr[1] & 0x0f) == IPV6_ADDR_MCAST_SCP_IF_LOCAL))

Check if address is a multicast node-local address.

Parameters
[in]addraddress of type const struct in6_addr *
Returns
0, when an address is not a multicast node-local address.
any other value otherwise.

Definition at line 142 of file in.h.

◆ IN6_IS_ADDR_MC_ORGLOCAL

#define IN6_IS_ADDR_MC_ORGLOCAL (   addr)
Value:
(int)((addr->s6_addr[1] & 0x0f) == IPV6_ADDR_MCAST_SCP_ORG_LOCAL))

Check if address is a multicast organization-local address.

Parameters
[in]addraddress of type const struct in6_addr *
Returns
0, when an address is not a multicast organization-local address.
any other value otherwise.

Definition at line 175 of file in.h.

◆ IN6_IS_ADDR_MC_SITELOCAL

#define IN6_IS_ADDR_MC_SITELOCAL (   addr)
Value:
(int)((addr->s6_addr[1] & 0x0f) == IPV6_ADDR_MCAST_SCP_SITE_LOCAL))

Check if address is a multicast site-local address.

Parameters
[in]addraddress of type const struct in6_addr *
Returns
0, when an address is not a multicast site-local address.
any other value otherwise.

Definition at line 164 of file in.h.

◆ IN6_IS_ADDR_MULTICAST

#define IN6_IS_ADDR_MULTICAST (   addr)    ((int)(ipv6_addr_is_multicast((const ipv6_addr_t *)(addr))))

Check if address is a multicast address.

Parameters
[in]addraddress of type const struct in6_addr *
Returns
0, when an address is not a multicast address.
any other value otherwise.

Definition at line 92 of file in.h.

◆ IN6_IS_ADDR_SITELOCAL

#define IN6_IS_ADDR_SITELOCAL (   addr)    ((int)(ipv6_addr_is_site_local((const ipv6_addr_t *)addr)))

Check if address is a site-local address.

Parameters
[in]addraddress of type const struct in6_addr *
Returns
0, when an address is not a site-local address.
any other value otherwise.

Definition at line 112 of file in.h.

◆ IN6_IS_ADDR_UNSPECIFIED

#define IN6_IS_ADDR_UNSPECIFIED (   addr)    ((int)(ipv6_addr_is_unspecified((const ipv6_addr_t *)(addr))))

Check if address is the unspecified address (::).

Parameters
[in]addraddress of type const struct in6_addr *
Returns
0, when an address is not the unspecified address.
any other value otherwise.

Definition at line 72 of file in.h.

◆ IN6_IS_ADDR_V4COMPAT

#define IN6_IS_ADDR_V4COMPAT (   addr)    ((int)(ipv6_addr_is_ipv4_compat((const ipv6_addr_t *)addr)))

Check if address is an IPv4-compatible address.

Parameters
[in]addraddress of type const struct in6_addr *
Returns
0, when an address is not an IPv4-compatible address.
any other value otherwise.

Definition at line 132 of file in.h.

◆ IN6_IS_ADDR_V4MAPPED

#define IN6_IS_ADDR_V4MAPPED (   addr)    ((int)(ipv6_addr_is_ipv4_mapped((const ipv6_addr_t *)addr)))

Check if address is an IPv4 mapped address.

Parameters
[in]addraddress of type const struct in6_addr *
Returns
0, when an address is not an IPv4 mapped address.
any other value otherwise.

Definition at line 122 of file in.h.

◆ SOCKADDR_MAX_DATA_LEN

#define SOCKADDR_MAX_DATA_LEN   (26)

Maximum data length for a socket address.

It is assumed that struct sockaddr_in6 is currently the longest socket address struct. As such it's data length is taken consisting of the IPv6 address (16 byte), the port (2 byte), the flow information (4 byte) and the scope ID (4 byte)

Definition at line 83 of file socket.h.

Typedef Documentation

◆ in_port_t

typedef uint16_t in_port_t

Internet port type.

Todo:
IPv6 option names

Definition at line 207 of file in.h.

Function Documentation

◆ accept()

int accept ( int  socket,
struct sockaddr *__restrict  address,
socklen_t *__restrict  address_len 
)

Accept a new connection on a socket.

The accept() function shall extract the first connection on the queue of pending connections, create a new socket with the same socket type protocol and address family as the specified socket, and allocate a new file descriptor for that socket. If the listen queue is empty of connection requests and O_NONBLOCK is not set on the file descriptor for the socket, accept() shall block until a connection is present. If the listen() queue is empty of connection requests and O_NONBLOCK is set on the file descriptor for the socket, accept() shall fail and set errno to [EAGAIN] or [EWOULDBLOCK]. The accepted socket cannot itself accept more connections. The original socket remains open and can accept more connections.

See also
The Open Group Base Specification Issue 7, accept
Parameters
[in]socketSpecifies a socket that was created with socket(), has been bound to an address with bind(), and has issued a successful call to listen().
[out]addressEither a null pointer, or a pointer to a sockaddr structure where the address of the connecting socket shall be returned. If address is not a null pointer, the address of the peer for the accepted connection shall be stored in the sockaddr structure pointed to by address, and the length of this address shall be stored in the object pointed to by address_len. If the actual length of the address is greater than the length of the supplied sockaddr structure, the stored address shall be truncated. If the protocol permits connections by unbound clients, and the peer is not bound, then the value stored in the object pointed to by address is unspecified.
[out]address_lenEither a null pointer, if address is a null pointer, or a pointer to a socklen_t object which on input specifies the length of the supplied sockaddr structure, and on output specifies the length of the stored address.
Returns
Upon successful completion, accept() shall return the non-negative file descriptor of the accepted socket. Otherwise, -1 shall be returned and errno set to indicate the error.

◆ bind()

int bind ( int  socket,
const struct sockaddr address,
socklen_t  address_len 
)

Bind a name to a socket.

The bind() function shall assign a local socket address address to a socket identified by descriptor socket that has no local socket address assigned. Sockets created with the socket() function are initially unnamed; they are identified only by their address family.

See also
The Open Group Base Specification Issue 7, bind
Parameters
socketSpecifies the file descriptor of the socket to be bound.
addressPoints to a sockaddr structure containing the address to be bound to the socket. The length and format of the address depend on the address family of the socket. If the address family of the socket is AF_UNIX and the pathname in address names a symbolic link, bind() shall fail and set errno to [EADDRINUSE].
address_lenSpecifies the length of the sockaddr structure pointed to by the address argument.
Returns
Upon successful completion, bind() shall return 0; otherwise, -1 shall be returned and errno set to indicate the error.

◆ connect()

int connect ( int  socket,
const struct sockaddr address,
socklen_t  address_len 
)

Connect a socket.

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.

See also
The Open Group Base Specification Issue 7, connect
Parameters
[in]socketSpecifies the file descriptor associated with the socket.
[in]addressPoints to a sockaddr structure containing the peer address. The length and format of the address depend on the address family of the socket.
[in]address_lenSpecifies the length of the sockaddr structure pointed to by the address argument.
Postcondition
The socket will be implicitly 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."
Returns
Upon successful completion, connect() shall return 0; otherwise, -1 shall be returned and errno set to indicate the error.

◆ getpeername()

int getpeername ( int  socket,
struct sockaddr *__restrict  address,
socklen_t *__restrict  address_len 
)

Get the name of the peer socket.

The getpeername() function shall retrieve the peer address of the specified socket, store this address in the sockaddr structure pointed to by the address argument, and store the length of this address in the object pointed to by the address_len argument.

See also
The Open Group Base Specification Issue 7, getpeername
Parameters
[in]socketSpecifies the file descriptor associated with the socket.
[out]addressPoints to a sockaddr structure containing the peer address. The length and format of the address depend on the address family of the socket.
[in,out]address_lenSpecifies the length of the sockaddr structure on input and the length of the stored address on output. If the address is greater than the length of the supplied sockaddr structure, the stored address shal be truncated.
Returns
Upon successful completion, getpeername() shall return 0; otherwise, -1 shall be returned and errno set to indicate the error.

◆ getsockname()

int getsockname ( int  socket,
struct sockaddr *__restrict  address,
socklen_t *__restrict  address_len 
)

Get the socket name.

The getsockname() function shall retrieve the locally-bound name of the specified socket, store this address in the sockaddr structure pointed to by the address argument, and store the length of this address in the object pointed to by the address_len argument.

See also
The Open Group Base Specification Issue 7, getsockname
Parameters
[in]socketSpecifies the file descriptor associated with the socket.
[out]addressPoints to a sockaddr structure containing the peer address. The length and format of the address depend on the address family of the socket.
[in,out]address_lenSpecifies the length of the sockaddr structure on input and the length of the stored address on output. If the address is greater than the length of the supplied sockaddr structure, the stored address shal be truncated.
Returns
Upon successful completion, getsockname() shall return 0; otherwise, -1 shall be returned and errno set to indicate the error.

◆ getsockopt()

static int getsockopt ( int  socket,
int  level,
int  option_name,
void *  option_value,
socklen_t option_len 
)
inlinestatic
Todo:
implement out these functions

Definition at line 483 of file socket.h.

◆ inet_ntop()

const char* inet_ntop ( int  af,
const void *restrict  src,
char *restrict  dst,
socklen_t  size 
)

Converts an IP address to its string representation.

Precondition
(af == AF_INET) || (af == AF_INET6)
Parameters
[in]afAddress family of src. Must be AF_INET or AF_INET6.
[in]srcAn IP address.
[out]dstThe resulting string representation.
[in]sizeLength of result.
Returns
dst, on success
NULL, if size was smaller than needed
NULL, if src or dst was NULL

◆ inet_pton()

int inet_pton ( int  af,
const char *  src,
void *  dst 
)

Converts an IP address string representation to a byte-represented IP address.

Precondition
(af == AF_INET) || (af == AF_INET6)
Parameters
[in]afAddress family of src. Must be AF_INET or AF_INET6.
[in]srcAn IP address string representation
[out]dstThe resulting byte representation
Returns
1, on success.
0, if src was malformed or input pointers were NULL.
-1, if af is not supported.

◆ listen()

int listen ( int  socket,
int  backlog 
)

Listen for socket connections and limit the queue of incoming connections.

See also
The Open Group Base Specification Issue 7, listen
Parameters
[in]socketSpecifies the file descriptor associated with the socket.
[in]backlogProvides a hint to the implementation which the implementation shall use to limit the number of outstanding connections in the socket's listen queue. Implementations may impose a limit on backlog and silently reduce the specified value. Normally, a larger backlog argument value shall result in a larger or equal length of the listen queue. Implementations shall support values of backlog up to SOMAXCONN, defined in <sys/socket.h>.
Returns
Upon successful completions, listen() shall return 0; otherwise, -1 shall be returned and errno set to indicate the error.

◆ recv()

static ssize_t recv ( int  socket,
void *  buffer,
size_t  length,
int  flags 
)
inlinestatic

Receive a message from a connected socket.

Shall receive a message from a connection-mode or connectionless-mode socket. It is normally used with connected sockets because it does not permit the application to retrieve the source address of received data.

See also
The Open Group Base Specification Issue 7, recv
Parameters
[in]socketSpecifies the socket file descriptor.
[out]bufferPoints to a buffer where the message should be stored.
[in]lengthSpecifies the length in bytes of the buffer pointed to by the buffer argument.
[in]flagsSpecifies the type of message reception. Support for values other than 0 is not implemented yet.
Returns
Upon successful completion, recv() shall return the length of the message in bytes. If no messages are available to be received and the peer has performed an orderly shutdown, recv() shall return 0. Otherwise, -1 shall be returned and errno set to indicate the error.

Definition at line 380 of file socket.h.

◆ recvfrom()

ssize_t recvfrom ( int  socket,
void *__restrict  buffer,
size_t  length,
int  flags,
struct sockaddr *__restrict  address,
socklen_t *__restrict  address_len 
)

Receive a message from a socket.

The recvfrom() function shall receive a message from a connection-mode or connectionless-mode socket. It is normally used with connectionless-mode sockets because it permits the application to retrieve the source address of received data.

See also
The Open Group Base Specification Issue 7, recvfrom
Parameters
[in]socketSpecifies the socket file descriptor.
[out]bufferPoints to a buffer where the message should be i stored.
[in]lengthSpecifies the length in bytes of the buffer pointed to by the buffer argument.
[in]flagsSpecifies the type of message reception. Support for values other than 0 is not implemented yet.
[out]addressA null pointer, or points to a sockaddr structure in which the sending address is to be stored. The length and format of the address depend on the address family of the socket.
[out]address_lenEither a null pointer, if address is a null pointer, or a pointer to a socklen_t object which on input specifies the length of the supplied sockaddr structure, and on output specifies the length of the stored address.
Returns
Upon successful completion, recvfrom() shall return the length of the message in bytes. If no messages are available to be received and the peer has performed an orderly shutdown, recvfrom() shall return 0. Otherwise, the function shall return -1 and set errno to indicate the error.

◆ send()

static ssize_t send ( int  socket,
const void *  buffer,
size_t  length,
int  flags 
)
inlinestatic

Send a message on a socket.

Shall initiate transmission of a message from the specified socket to its peer. The send() function shall send a message only when the socket is connected. If the socket is a connectionless-mode socket, the message shall be sent to the pre-specified peer address.

See also
The Open Group Base Specification Issue 7, send
Parameters
[in]socketSpecifies the socket file descriptor.
[in]bufferPoints to the buffer containing the message to send.
[in]lengthSpecifies the length of the message in bytes.
[in]flagsSpecifies the type of message reception. Support for values other than 0 is not implemented yet.
Returns
Upon successful completion, send() shall return the number of bytes sent. Otherwise, -1 shall be returned and errno set to indicate the error.

Definition at line 450 of file socket.h.

◆ sendto()

ssize_t sendto ( int  socket,
const void *  buffer,
size_t  length,
int  flags,
const struct sockaddr address,
socklen_t  address_len 
)

Send a message on a socket.

Shall send a message through a connection-mode or connectionless-mode socket. If the socket is a connectionless-mode socket, the message shall be sent to the address specified by address 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 address (overriding the pre-specified peer address), or the function shall return -1 and set errno to EISCONN.

See also
The Open Group Base Specification Issue 7, sendto
Parameters
[in]socketSpecifies the socket file descriptor.
[in]bufferPoints to the buffer containing the message to send.
[in]lengthSpecifies the length of the message in bytes.
[in]flagsSpecifies the type of message reception. Support for values other than 0 is not implemented yet.
[in]addressPoints to a sockaddr structure containing the destination address. The length and format of the address depend on the address family of the socket.
[in]address_lenSpecifies the length of the sockaddr structure pointed to by the address argument.
Postcondition
The socket will implicitly 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 Generic (GNRC) network stack any 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.
Returns
Upon successful completion, send() shall return the number of bytes sent. Otherwise, -1 shall be returned and errno set to indicate the error.

◆ socket()

int socket ( int  domain,
int  type,
int  protocol 
)

Create an endpoint for communication.

Shall create an unbound socket in a communications domain, and return a file descriptor that can be used in later function calls that operate on sockets.

Parameters
[in]domainSpecifies the communications domain in which a socket is to be created. Valid values are prefixed with `AF_ and defined in socket.h.
[in]typeSpecifies the type of socket to be created. Valued values are prefixed with SOCK_ and defined in socket.h.
[in]protocolSpecifies a particular protocol to be used with the socket. Specifying a protocol of 0 causes socket() to use an unspecified default protocol appropriate for the requested socket type.
Returns
Upon successful completion, socket() shall return a non-negative integer, the socket file descriptor. Otherwise, a value of -1 shall be returned and errno set to indicate the error.
IPV6_ADDR_MCAST_SCP_GLOBAL
#define IPV6_ADDR_MCAST_SCP_GLOBAL
global scope
Definition: addr.h:255
IPV6_ADDR_MCAST_SCP_IF_LOCAL
#define IPV6_ADDR_MCAST_SCP_IF_LOCAL
interface-local scope
Definition: addr.h:238
IPV6_ADDR_MCAST_SCP_ORG_LOCAL
#define IPV6_ADDR_MCAST_SCP_ORG_LOCAL
organization-local scope
Definition: addr.h:254
IPV6_ADDR_MCAST_SCP_SITE_LOCAL
#define IPV6_ADDR_MCAST_SCP_SITE_LOCAL
site-local scope
Definition: addr.h:253
IPV6_ADDR_MCAST_SCP_LINK_LOCAL
#define IPV6_ADDR_MCAST_SCP_LINK_LOCAL
link-local scope
Definition: addr.h:239
IN6_IS_ADDR_MULTICAST
#define IN6_IS_ADDR_MULTICAST(addr)
Check if address is a multicast address.
Definition: in.h:92