This function returns the standard host name for the local computer.
At a Glance
Header file: | Winsock.h |
Windows CE versions: | 1.0 and later |
Syntax
int gethostname (char *name, int namelen);
Parameters
name
[out] Pointer to a buffer that receives the local host name.
namelen
[in] Buffer length.
Return Values
Zero indicates no error occurred. SOCKET_ERROR indicates failure. To get a specific error value, call WSAGetLastError.
Remarks
The gethostname function returns the local host name into the buffer specified by the name parameter. The host name is returned as a null-terminated string. The host name form is dependent on the Windows Sockets provider—it can be a simple host name, or it can be a fully qualified domain name. However, it is guaranteed that the name returned will be successfully parsed by gethostbyname.
Note If no local host name has been configured, gethostname must succeed and return a token host name that gethostbyname can resolve.
See Also