IPX/SPX Programming Manual
Library Routines
HP NonStop IPX/SPX Programming Manual—528022-001
5-26
getsockname, getsockname_nw
address_len_ptr
is maintained only for compatibility and should be a value indicating the size in
bytes of the IPX address data structure pointed to by address_ptr.
tag
is the tag parameter to be used for the nowait operation initiated by
getsockname_nw.
Errors
If an error occurs, the external variable errno is set to the following value:
Usage Guidelines
•
Use getsockname on a socket created for waited operations, or use
getsockname_nw on a socket created for nowait operations. The operation
initiated by getsockname_nw must be completed with a call to the AWAITIOX
procedure.
•
IPX/SPX, this function does not return an address when called on an unbound IPX
socket. In addition, this function does not return a port number for an unconnected
IPX socket until the first I/O operation on the socket is completed. This is typical of
socket implementations. An IPX socket is implicitly bound after the first sendto
call.
For information on error checking, see Nowait Call Errors on page 5-5.
For information about struct sockaddr_nv and struct sockaddr, see NonStop
IPX/SPX Data Structures on page 4-2.
Example
The following programming example obtains the address and port number to which the
socket change is bound:
#include <socket.h>
#include <nv.h>
#include <netdb.h>
struct sockaddr_nv lcl;
optlen = sizeof(lcl);
if (getsockname(chan,(struct sockaddr *)&lcl, &optlen) < 0)
perror (“Get socket name failed.”);
/* Code to use the address and port number. */
EINVAL An invalid argument was specified.