HP X.25/9000 Programmer's Guide

Chapter 6 109
Extended Features
Getting Programmatic Diagnostics and Status Information
Syntax for getpeername()
getpeername() 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 addr;
addrlen = sizeof(struct x25addrstr);
error = getpeername(sd, &addr, addrlen);
sd Socket descriptor for the socket whose peer address will be returned.
addr If the call completes successfully, this
x25addrstr
structure contains the
X.121 address of the remote DTE. This information is useful when using
wildcard addressing and when reestablishing a terminated connection.
addrlen If the call completes successfully,
addrlen
contains the length in bytes of
the
x25addrstr
structure pointed to by
addr
. Before calling
getpeername(), this field must be initialized with the size of the
x25addrstr
structure.
error If the call completes successfully,
error
contains 0. Otherwise, –1 is
returned and
errno
contains the cause of the error.
Refer to the getsockname(2) entry in your man pages for more
information.
Syntax for getsockname()
The getsockname() 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 addr;
addrlen = sizeof(struct x25addrstr);
error = getsockname(sd, &addr, &addrlen);
sd Socket descriptor for the socket whose addressing information is being
36960-90061.bk Page 109 Friday, November 10, 2000 3:42 PM