Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
System Functions (a - d) connect(2)
NAME
connect - Connects a socket
LIBRARY
G-series native OSS processes: system library
H-series and J-series OSS processes: implicit libraries
32-bit H-series and J-series OSS processes that use the POSIX User Thread Model library:
/G/system/zdllnnn/zputdll
64-bit H-series and J-series OSS processes that use the POSIX User Thread Model library:
/G/system/zdllnnn/yputdll
SYNOPSIS
#define _XOPEN_SOURCE_EXTENDED 1
#include <sys/socket.h>
int connect(
int socket,
const struct sockaddr *address,
socklen_t address_len);
PARAMETERS
socket Specifies the file 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 Specifies 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. In systems running
AF_UNIX Release 2 software, both sockets must use the same mode (compatibility or portabil-
ity). For more information about AF_UNIX Release 2, see the Open System Services
Programmer’s Guide.
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 identifies 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.
527186-023 Hewlett-Packard Company 1−37