Converts a socket address to a host name and port number.
The rpc_$sockaddr_to_name routine provides the address family, the host name, and the port number identified by the specified socket address.
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. |
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;