rpc_$sockaddr_to_name Library Routine

Purpose

Converts a socket address to a host name and port number.

Syntax

void rpc_$sockaddr_to_name ( sockaddr,  slength,  name,  nlength,  port,  status)
socket_$addr_t *sockaddr;
unsigned long slength;
unsigned long *nlength;
char *name;
unsigned long *port;
status_$t *status;

Description

The rpc_$sockaddr_to_name routine provides the address family, the host name, and the port number identified by the specified socket address.

Parameters

Input

Item Description
sockaddr Points to a socket address.
slength Specifies the length, in bytes, of socket address (sockaddr) parameter.

Input/Output

Item Description
nlength On input, points to the length of the name parameter in the buffer. On output, points to the number of characters returned in the name parameter.

Output

Item Description
name Points to a character string that contains the host name and the address family in the format: family:host. The value of the family parameter must be ip.
port Points to the socket port number.
status Points to the completion status.

Examples

To take the bank server's socket address, return the server's host name and port, and then print the information, enter:

rpc_$sockaddr_to_name(&saddr, slen, name, &namelen, &port, &st);
  printf("(bankd) name=\"%.*s\", port=%d\n", name, namelen, port;