Jump to main content

##

# 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

Parameters | Description
--- | ---
s | Socket descriptor returned from a previous call to socket.
name | Pointer to the sockaddr structure containing the local address of the socket.
namelen | Length of the sockaddr structure.

## Returns

- 0 - The function was successful.
- SOCKET_ERROR - Function failed. errno is set accordingly.

## Remarks

None.