gtpc1m3qTransmission Control Protocol/Internet Protocol

gethostid -- Return Identifier of Current Host

The gethostid function gets the unique 32-bit identifier for the current host.

Format

#include  <types.h>
#include  <socket.h>
int      gethostid(void);

Normal Return

Return code 0 indicates that the function was successful. The gethostid call returns the 32-bit identifier, in host byte order of the current host, which must be unique across all hosts.

Error Return

A return code equal to -1 indicates an error. You can get the specific error code by calling sock_errno. See Appendix C, Socket Error Return Codes for more information about socket errors.

Note:
Unless otherwise stated in the description, the following error codes can be returned for either TCP/IP offload support or TCP/IP native stack support.

Value
Description

SOCNOBUFS
There is not enough buffer space to process this function. This error code is returned only for TCP/IP offload support.

EIBMIUCVERR
An error occurred when the function was sent to the offload device. This error code is returned only for TCP/IP offload support.

E1052STATE
The socket was closed because the system was in or cycling down to 1052 state.

EINACT
All offload devices associated with the socket descriptor have been disconnected. The socket is closed. This error code is returned only for TCP/IP offload support.

EINACTWS
An offload device associated with the socket descriptor has been disconnected. The socket is still available. This error code is returned only for TCP/IP offload support.

ESYSTEMERROR
A system error has occurred and closed the socket. This error code is returned only for TCP/IP offload support.

OFFLOADTIMEOUT
A response was not received from the offload device in a specified time period. This error code is returned only for TCP/IP offload support.

SOCFAULT
There are no IP addresses defined to the TPF system. This error code is returned only for TCP/IP native stack support.

Programming Considerations

The output of gethostid is either X or Y, where X is the default local IP address (see Default Local IP Address for more information) and Y is the IP address of the first active and connected offload device. To determine the output of gethostid, consider the following:

Examples

The following example obtains the host Internet Protocol (IP) address.

#include <types.h>
#include <socket.h>

·
·
·
u_long hostid;
·
·
·
hostid = gethostid();

Related Information

None.