Open System Services System Calls Reference Manual (G06.25+, H06.03+)

System Functions (a - d) connect(2)
NAME
connect - Connects a socket
LIBRARY
G-series native OSS processes: system library
H-series OSS processes: implicit libraries
SYNOPSIS
#include <sys/socket.h>
int connect(
int socket,
const struct sockaddr *address,
size_t address_len
);
PARAMETERS
socket Species the le descriptor for the socket.
address Points to a sockaddr structure that contains the address of the peer socket. The
length and format of the address depend on the address family of the socket.
For AF_INET sockets, a pointer to the address structure sockaddr_in must be
cast as a struct sockaddr.ForAF_INET6 sockets, a pointer to the address
structure sockaddr_in6 must be cast as a struct sockaddr.ForAF_UNIX sock-
ets, a pointer to the address structure sockaddr_un must be cast as a struct
sockaddr.
address_len Species the length of the sockaddr structure pointed to by the address parame-
ter.
DESCRIPTION
The connect() function requests that a connection be made on a socket.
The connect() function performs a different action for each of the following types of initiating
sockets:
If the initiating socket is not connection-oriented (has the type SOCK_DGRAM), then
the connect() function sets the peer address but no connection is made. The peer
address identies the socket where all datagrams are sent by subsequent calls to the
send() function, and limits the remote sender for subsequent recv() function calls.
Datagram sockets can use the connect() function multiple times to communicate with
different peers.
If the socket is a datagram socket and address is a null address for the protocol, the
address for the peer socket is reset.
If the initiating socket is connection-oriented (has the type SOCK_STREAM), then the
connect() function attempts to make a connection to the socket specied by the address
parameter. Sockets of type SOCK_STREAM can successfully connect only once.
When a connection cannot be created immediately and O_NONBLOCK is not set for the le
descriptor of the socket, the connect() call blocks until one of the following occurs:
A connection is established
A timeout occurs
A signal is caught
527186-003 Hewlett-Packard Company 127