HP X.25/9000 Programmer's Guide
Chapter 3 31
Establishing and Terminating a Socket Connection
Connection Establishment for the Server Process
Accepting a connection
The accept() system call returns a socket descriptor for a socket
associated with an SVC connection. This call usually establishes a
connection when returned, although that can also be controlled by the
application. The transmission of the CALL ACCEPTED packet and its
contents can be controlled with ioctl(X25_CALL_ACPT_APPROVAL) and
ioctl(X25_SEND_CALL_ACEPT). These ioctl() calls are described
below.
The accept() call blocks the socket until a CALL REQUEST packet
arrives (unless the listen socket is set to nonblocking mode).
Syntax for accept()
The accept() system call and its parameters are described below.
#include <sys/types.h>
#include <sys/socket.h>
#include <x25/x25addrstr.h>
int sd, fromlen;
struct x25addrstr from;
int new_sd;
fromlen = sizeof(struct x25addrstr);
new_sd = accept(sd, &from, &fromlen);
sd The socket descriptor used in a previous listen() call.
from On successful completion, this x25addrstr structure contains the name
of the local interface that received the call and the calling address and
subaddress, if any, of the DTE which sent the CALL REQUEST packet.
This information is useful when using wildcard addressing (see Chapter
2 , “X.25 Addressing,”).
fromlen Before calling accept(), this field must be initialized with the size
declared in the x25addrstr structure. On successful completion, this
integer contains the length of the x25addrstr structure in bytes.
new_sd If the connection is successful,
new_sd
contains a socket descriptor for a
new socket which is connected to the incoming call. If an error is
encountered, –1 is returned in
new_sd
and
errno
contains the error code.
An accept() call usually returns a CALL ACCEPTED packet. However,
the content and transmission of this packet can be controlled by the
application. The ioctl(X25_CALL_ACPT_APPROVAL) and
36960-90061.bk Page 31 Friday, November 10, 2000 3:42 PM










