Both connect()
and bind()
system calls \'associate\' the socket file descriptor to an address (typically an ip/port combination). Their prototypes
The one liner : bind()
to own address, connect()
to remote address.
Quoting from the man page of bind()
bind() assigns the address specified by addr to the socket referred to by the file descriptor sockfd. addrlen specifies the size, in bytes, of the address structure pointed to by addr. Traditionally, this operation is called "assigning a name to a socket".
and, from the same for connect()
The connect() system call connects the socket referred to by the file descriptor sockfd to the address specified by addr.
To clarify,
bind()
associates the socket with its local address [that's why
server side bind
s, so that clients can use that address to connect
to server.]connect()
is used to connect to a remote [server] address, that's
why is client side, connect [read as: connect to server] is used.