bind

Top  Previous  Next

The bind function associates a local address with a socket.

It assigns a local socket address, specified by the argument myAddr to a socket identified by the descriptor socket that has no local socket address assigned.

 

Syntax

int bind(

int socket,

const struct sockaddr *myAddr,

int addrLen

);

 

Parameters

socket

A descriptor identifying an unbound socket.

 

myAddr

Points to a sockaddr structure containing the address to be bound to the socket.

 

addrLen

Length of the sockaddr structure pointed by myAddr, in bytes.

 

Return value

If no error occurs, bind returns 0 otherwise it returns -1. If an error occurs errno indicates the error.