The ACCEPT macro is issued when the server receives a
connection request from a client. ACCEPT points to a socket that was
created with a SOCKET macro and marked by a LISTEN macro. If a process
waits for the completion of connection requests from several peer
processes, a later ACCEPT macro can block until one of the CONNECT
macros completes. To avoid this, issue a SELECT macro between the
CONNECT and the ACCEPT macros. Concurrent server programs use the
ACCEPT macro to pass connection requests to subtasks.
When issued, the ACCEPT macro takes the following actions:
- Accepts the first connection on a queue of pending connections.
- Creates a new socket with the same properties as the socket used
in the macro and returns the address of the client for use by subsequent
server macros. The new socket cannot be used to accept new connections,
but can be used by the calling program for its own connection. The
original socket remains available to the calling program for more
connection requests.
- Returns the new socket descriptor to the calling program.
The following requirements apply to this call:
Authorization: |
Supervisor state or problem state, any PSW key. |
Dispatchable unit mode: |
Task. |
Cross memory mode: |
PASN = HASN. |
Amode: |
31-bit or 24-bit.
|
ASC mode: |
Primary address space control (ASC) mode. |
Interrupt status: |
Enabled for interrupts. |
Locks: |
Unlocked. |
Control parameters: |
All parameters must be addressable by the caller
and in the primary address space. |
>>-EZASMI--TYPE=ACCEPT--,S--=--+-number---+--------------------->
+-address--+
+-*indaddr-+
'-(reg)----'
>--,NAME--=--+-address--+--,ERRNO--=--+-address--+-------------->
+-*indaddr-+ +-*indaddr-+
'-(reg)----' '-(reg)----'
>--,RETCODE--=--+-address--+--+----------------------+---------->
+-*indaddr-+ '-,NS--=--+-number---+-'
'-(reg)----' +-address--+
+-*indaddr-+
'-(reg)----'
>--+---------------------------+--+-------------------------+--->
+-,ECB--=--+-address--+-----+ '-,ERROR--=--+-address--+-'
| +-*indaddr-+ | +-*indaddr-+
| '-(reg)----' | '-(reg)----'
'-,REQAREA--=--+-address--+-'
+-*indaddr-+
'-(reg)----'
>--+------------------------+----------------------------------><
'-,TASK--=--+-address--+-'
+-*indaddr-+
'-(reg)----'
- Keyword
- Description
- S
- Input parameter. A value or the
address of a halfword binary number specifying the descriptor of the
socket from which the connection is accepted.
- NAME
-
Output parameter. Initially, the IPv4 or IPv6 application
provides a pointer to the IPv4 or IPv6 socket address structure, which
is filled on completion of the call with the socket address of the
connection peer. Include the SYS1.MACLIB(BPXYSOCK) macro to get the
assembler mappings for the socket address structure. The socket address
structure mappings begin at the SOCKADDR label. The AF_INET socket
address structure fields start at the SOCK_SIN label. The AF_INET6
socket address structure fields start at the SOCK_SIN6 label.
The IPv4 socket address structure contains the following fields:
- Field
- Description
- FAMILY
- A halfword binary field specifying the IPv4 addressing family.
For IPv4 the value is a decimal 2, indicating AF_INET.
- PORT
- A halfword binary field that is set to the client port number.
- IPv4-ADDRESS
- A fullword binary field that is set to the 32-bit IPv4 Internet
address, in network byte order, of the client host machine.
- RESERVED
- Specifies eight bytes of binary zeros. This field is required,
but not used.
The IPv6 socket address structure contains the following
fields: - Field
- Description
- NAMELEN
- A 1-byte binary field specifying the length of this IPv6 socket
address structure. Any value specified by the use of this field is
ignored when processed as input and the field is set to 0 when processed
as output.
- FAMILY
- A 1-byte binary field specifying the IPv6 addressing family. For
IPv6 the value is a decimal 19, indicating AF_INET6.
- PORT
- A halfword binary field that is set to the client port number.
- FLOW-INFO
- A fullword binary field specifying the traffic class and flow
label. This value of this field is undefined.
- IPv6-ADDRESS
- A 16-byte binary field that is set to the 128-bit IPv6 Internet
address, in network byte order, of the client host machine.
- SCOPE-ID
- A fullword binary field which identifies a set of interfaces as
appropriate for the scope of the address carried in the IPv6-ADDRESS field. For a link scope IPv6-ADDRESS, SCOPE-ID contains the link index
for the IPv6-ADDRESS. For all other address
scopes, SCOPE-ID is undefined.
- ERRNO
- Output parameter. A fullword binary
field. If RETCODE is negative, ERRNO contains a valid error number. Otherwise, ignore ERRNO.
See Socket call error return codes for information
about ERRNO return codes.
- RETCODE
- Output parameter. If RETCODE is positive, RETCODE is
the new socket number.
If RETCODE is negative,
check ERRNO for an error number.
- Value
- Description
- >0
- Successful call.
- -1
- Check ERRNO for an error code.
- NS
- Input parameter. A value or the address of a halfword
binary number specifying the descriptor number chosen for the new
socket, which is the socket for the client at the time. If NS is not
specified, the interface assigns it.
- ECB or REQAREA
- Input parameter. This parameter is required if you are
using APITYPE=3. It points to a 104-byte field containing:
- For ECB
- A 4-byte ECB posted by TCP/IP when the
macro completes.
- For REQAREA
- A 4-byte user token (set by you) that is presented to your exit
when the response to this function request is complete.
- For ECB/REQAREA
- The last 100 bytes is a storage field used by the interface to
save the state information.
Note: This storage must not be modified until the
macro function has completed and the ECB has
been posted, or the asynchronous exit has been driven.
- ERROR
- Input parameter. The location in your program to receive
control when the application programming interface (API) processing
module cannot be loaded.
- TASK
- Input parameter. The location of the task storage area in your
program.