HP X.25/9000 Programmer's Guide

28 Chapter3
Establishing and Terminating a Socket Connection
Connection Establishment for the Server Process
must specify AF_CCITT.
type Identifies the type of socket. For X.25 programmatic access, you must
specify SOCK_STREAM.
protocol Identifies the underlying protocol to be used for the socket. For X.25
programmatic access, specify X25_PROTO_NUM (or 0 to specify that the
default, which is
X25_PROTO_NUM
, is used).
sd If the connection is successful,
sd
contains the socket descriptor for the
newly-created socket. If the system call encountered an error, –1 is
returned in
sd
and
errno
contains the error code.
The socket descriptor returned by socket() references the
newly-created socket. This descriptor is used for the subsequent system
calls used to establish an SVC (bind(), listen(), and accept()).
Refer to the socket(2) entry in your man pages for more information.
Binding an X.121 Address to a Socket
After your server process has created a socket and before a listen()
system call is executed, the server must call bind() to associate an
X.121 address to the socket. Until an address is bound to the server
socket X.25 cannot reach your server.
Syntax for bind()
The bind() system call and its parameters are described below.
#include <sys/types.h>
#include <sys/socket.h>
#include <x25/x25addrstr.h>
int error;
int sd, addrlen;
struct x25addrstr bind_addr;
addrlen = sizeof(struct x25addrstr);
error = bind(sd, &bind_addr, addrlen)
sd Socket (returned from a previous socket() system call) to which the
address will be bound.
bind_addr x25addrstr structure which contains addressing information. The
addressing information defines the types of CALL REQUEST packets
36960-90061.bk Page 28 Friday, November 10, 2000 3:42 PM