This function initiates a connection on a socket. If s is a socket descriptor of type SOCK_DGRAM, then this call permanently specifies the peer where the data is sent. If s is of type SOCK_STREAM, then this call attempts to make a connection to the specified socket. If a call to connect() fails for a connection-mode socket, applications should use close() to deallocate the socket and descriptor. If attempting to reinitiate the connection, applications should create a new socket. Related Functions See also accept(), select(), socket(), getsockname(), and shutdown().