CONNECT

The CONNECT call is issued by a client to establish connection with a server.

The call performs the following two tasks:
  1. Completes the binding process if a BIND call has not been previously issued.
  2. Attempts to make a connection to a remote socket. This connection is necessary before data can be transferred.
The following call sequence is issued by the client and server:
  1. The server issues BIND and LISTEN calls to create a passive open socket.
  2. The client issues a CONNECT call to request the connection.
  3. The server accepts the connection on the passive open socket, creating a new connected socket.
The CONNECT call blocks the calling program until the connection is established or until an error is received. The completion cannot be checked by issuing a second CONNECT call.

Example of CONNECT call

SOC_FUNCTION DC  CL16'CONNECT'
S            DS  H
NAME         DS  0XL28
FAMILY       DS  H
PORT         DS  H
IP_ADDRESS   DS  CL16
RESERVED     DS  CL8
ERRNO        DS  F
RETCODE      DS  F
 
 
    CALL DFHSOKET,(SOC_FUNCTION,S,,NAME,ERRNO,RETCODE)

Input parameters

SOC_FUNCTION
A 16-byte field containing CONNECT. Left-justify the field and pad it on the right with blanks.
S
A halfword binary number specifying the socket descriptor of the socket that is to be used to establish a connection.
NAME
A structure that contains the socket address of the target to which the local client socket is to be connected.
FAMILY
A halfword binary field specifying the addressing family. FAMILY must match the value assigned to the AF field used in the SOCKET function request.
PORT
A halfword binary field that is set to the server port number in network byte order. For example, if the port number is 5000 in decimal, it is stored as X'1388' in hex.
IP_ADDRESS
A 16-byte field that is set to the IPv4 or IPv6 internet address of the socket to be bound. If FAMILY is set to 2 (denoting an AF_NET socket), the address is an IPv4 address and the first 4 bytes of IP_ADDRESS are used. For more information on AF_INET and AF_INET6, see the z/OS Communications Server: IP Configuration Guide.
RESERVED
Specifies an 8-byte reserved field. This field is required, but is not used.

Output parameters

ERRNO
A fullword binary field. If RETCODE is negative, this field contains an error number. See Return codes for information about ERRNO return codes.
RETCODE
A fullword binary field that returns one of the following values:
Value
Description
0
Successful call
-1
Check ERRNO for an error code