Embedded TCP/IP stack
4.7.0
|
fnet_return_t fnet_socket_bind | ( | fnet_socket_t | s, |
const struct fnet_sockaddr * | name, | ||
fnet_size_t | namelen | ||
) |
Assigns a local address to a socket.
s | Descriptor, identifying a socket to bind. |
name | The address to be assigned to the socket, from the fnet_sockaddr structure. |
namelen | The length of the name parameter. Normally namelen is set to sizeof(name) . |
This function associates a local address with the socket.
The fnet_socket_bind() function is used on an unconnected socket before subsequent calls to the fnet_socket_connect() or the fnet_socket_listen() functions. It is used to bind to either connection-oriented (stream) or connectionless (datagram) sockets.
Within the fnet_sockaddr structure, the address may be the address assigned to a network interface on the host or the INADDR_ANY. Using the INADDR_ANY causes the stack to use the default network interface address. Using a port number of 0 causes the service provider to assign a unique ephemeral port number to the socket with a value between 49152 to 65535 (sugested by IANA)