BIND
In a typical server program, the BIND call follows a SOCKET call and completes the process of creating a new socket.
The BIND call can either specify the required port or let the system choose the port. A listener program always binds to the same well-known port, so that clients know which socket address to use when attempting to connect.
The BIND call can specify the networks from which it will accept connection requests. The program can fully specify the network interface by setting the ADDRESS field to the internet address of a network interface. Alternatively, the program can use a wildcard to specify that it will receive connection requests from any network interface. Set the ADDRESS field to a fullword of zeros for a wildcard.
Example of BIND call
SOC_FUNCTION DC CL16'BIND'
S DS H
NAME DS 0XL16
FAMILY DS H
PORT DS H
IP_ADDRESS DS F
RESERVED DS CL8
ERRNO DS F
RETCODE DS F
CALL DFHSOKET,(SOC_FUNCTION,S,NAME,ERRNO,RETCODE)Input parameters
- SOC_FUNCTION
- A 16-byte character field containing
BIND. The field is left-justified and padded to the right with blanks. - S
- A halfword binary number specifying the socket descriptor for the socket to be bound.
- NAME
- Specifies the socket address structure for the socket that is
to be bound.
- FAMILY
- A halfword binary field specifying the addressing family. The call returns 2 for the AF_INET socket. For more information on AF_INET and AF_INET6, see the z/OS® 1.9 Communications Server IPv6 Network and Application Design Guide.
- PORT
- A halfword binary field that is set to the port number to which
you want the socket to be bound. Note: If PORT is set to 0 when the call is issued, the system assigns the port number for the socket. The program can call the GETSOCKNAME call after the BIND call to discover the assigned port number.
- IP_ADDRESS
- A fullword binary field that is set to the 32-bit IPv4 address (network byte order) of the socket to be bound. IPv6 addressing is not supported.
- RESERVED
- Specifies an 8-byte character field that is required but 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:
- Value
- Description
- 0
- Successful call
- -1
- Check ERRNO for an error code