TCP/IP Programming Manual
/* Notice from is cast to struct sockaddr in the following call
as suggested in the Usage Guidelines */
if ((s2 = accept(fd, (struct sockaddr *)&from, &flen)) < 0) {
perror ("Server: Accept failed.");
exit (0);
}
inet_ntop(AF_INET6, &from.sin6_addr, buf, sizeof(buf));
printf ("Server Connected from remote %s.%d\n", buf, from.sin6_port);
accept_nw
The accept_nw function checks for connections on an existing nowait socket. It is designed to be
followed first by a call to socket_nw to create a new socket, then a call to accept_nw2 to accept
the connection on the new socket.
C Synopsis
#include <socket.h>
#include <in.h>
#include <in6.h> /* if using IPv6 */
#include <netdb.h>
error = accept_nw (socket, from_ptr, from_len1, tag);
int error, socket;
struct sockaddr *from_ptr;
int *from_len1;
long tag;
TAL Synopsis
?NOLIST, SOURCE SOCKDEFT
?NOLIST, SOURCE SOCKPROC
error := accept_nw (socket, from_ptr, from_len1, tag);
INT(32) error;
INT(32) socket;
INT .EXT from_ptr (sockaddr_in);
INT .EXT from_len1;
INT(32) tag;
error
return value. If the call is successful, a zero is returned. If the call is not successful, –1 is returned.
If the call failed, the external variable errno is set as indicated in Errors (page 201).
socket
input and return value; specifies the socket number, created by a previous socket_nw call,
to be used to check for connections.
from_ptr
input and return value; points, on return, to the remote address and port number for the new
connection from which the connection was initiated.
from_len1
input and return value; points to a value indicating the size in bytes of the structure pointed to
by from_ptr. Set the from_len1 used in the accept_nw call to point to the size of the
sockaddr struct before making the call. accept_nw then returns the remote client’s IP address
in the from_ptr parameter of the sockaddr or sockaddr_in6 struct. This is an input
parameter.
accept_nw 91