The following code accepts a connection and reads the
first block of data from a client. The new socket's descriptor,
the peer's remote
address and the caller's local address
are also returned. SOCKDESC was previously set by a call to
BPX1SOC. ACPSOCK must be set to -1 and the system will assign
a new descriptor for the accepted connection in this parameter.
A bind and a listen must also have been
previously done.
The SOCKADDR was built by the call to BPX1BND. For the callable
service, see
accept_and_recv (BPX1ANR, BPX4ANR) — Accept a connection and receive the first block of data.
For the data structure, see
BPXYSOCK — Map SOCKADDR structure and constants.
AMODE 64 callers use
BPX4ANR (accept_and_recv) example.
L R8,=XL4'FFFFFFFF' Set ACPSOCK = -1
ST R8,ACPSOCK
CALL BPX1ANR, Accept_and_receive request +
(SOCKDESC, Input: Socket descriptor +
ACPSOCK, Input: -1 Output: accepted soc des+
SOCK#LEN+SOCK_SUN#LEN, Input/Output: Len of Remote_addr +
RSOCKADR, Input: Remote sockaddr structure +
SOCK#LEN+SOCK_SUN#LEN, Input/Output: Len of Local_addr +
LSOCKADR, Input: Local sockaddr structure +
=A(L'BUFFERA), Input: Length of the buffer +
BUFFERA, Input/Output: Addr of the buffer +
PRIMARYALET, Input: Alet of the buffer +
RETVAL, Return value: -1 or num bytes recd+
RETCODE, Return code +
RSNCODE), Reason code +
VL,MF=(E,PLIST) ----------------------------------
L R2,RETVAL
ST R2,BYTERECD Store number of bytes received