bind Function

C

int bind(
    SOCKET s, 
    const struct sockaddr* name, 
    int namelen
);

Description

The bind function assigns a name to an unnamed socket. The name represents the local address of the communication endpoint. For sockets of type SOCK_STREAM, the name of the remot endpoint is assigned when a connect or accept function is executed.

Preconditions

The socket function should be called.

Parameters

ParametersDescription
sSocket descriptor returned from a previous call to socket.
namePointer to the sockaddr structure containing the local address of the socket.
namelenLength of the sockaddr structure.

Returns

  • 0 - The function was successful.

  • SOCKET_ERROR - Function failed. errno is set accordingly.

Remarks

None.