TCP/IP Programming Manual

tag
input value; the tag parameter to be used for the nowait operation.
Errors
If an error occurs, the external variable errno is set to one of the following values:
There is already an outstanding call on the socket.EALREADY
The connection was reset by the peer process before the accept_nw operation completed.ECONNRESET
An invalid argument was specified.EINVAL
Usage Guidelines
The accept_nw function is designed to be followed first by a call to socket_nw to create
a new socket, then by a call to accept_nw2. The from_ptr parameter from accept_nw
is passed to accept_nw2, which accepts the connection on the new socket.
Use accept_nw2 after this call.
This is a nowait call; it must be completed with a call to the Guardian procedure AWAITIOX.
For a waited call, use accept.
The accept_nw call causes TCP/IP to do a listen and accept in one call.
Declare the from_ptr variable as type struct sockaddr_in6 * for IPv6 use or as type
struct sockaddr_storage * for protocol-independent use. In C, when you make the
call, cast the variable to sockaddr *. (See the IPv6 example.)
For the Conventional TCP/IP product only, it is not recommended to use CANCEL or CANCELREQ
calls with accept_nw. While this procedure works as expected with IPv6 and CIP products,
with Conventional TCP/IP, accept_nw causes a pending incoming connection to be
immediately marked as allocated and the cancel does not undo this. Subsequent accept_nw
requests require additional incoming connections for the requests to complete. Because the
connection has been marked allocated it cannot be accepted by a subsequent accept_nw.
See Nowait Call Errors (page 86) for information on error checking.
See Chapter 3 (page 62) for information about struct sockaddr, struct sockaddr_in6,
and struct sockaddr_storage.
Example
INET: The following IPv4 TCP server programming example calls accept_nw, socket_nw, and
accept_nw2. This call accepts a connection on the new socket fd2 created for nowait data
transfer.
#include <socket.h>
#include <in.h>
#include <netdb.h>
...
struct sockaddr_in from;
...
if ((fd1 = socket_nw(AF_INET, SOCK_STREAM,,1,1)) < 0) {
perror ("Server Socket 1 create failed.");
exit (0);
/* Call AWAITIOX */
}
/* Before calling accept_nw, program must call bind_nw and
* listen. A call to AWAITIOX must follow the bind_nw call.
*/
92 Library Routines