gethostname
The Windows Sockets gethostname function returns the standard host name for the local machine.
int gethostname (
char FAR * name,
int namelen
);
Parameters
name
[out] A pointer to a buffer that receives the local host name.
namelen
[in] The length of the buffer.
Remarks
The gethostname function returns the name of the local host into the buffer specified by the name parameter. The host name is returned as a null-terminated string. The form of the host name 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 and WSAAsyncGetHostByName.
Note If no local host name has been configured, gethostname must succeed and return a token host name that gethostbyname or WSAAsyncGetHostByName can resolve.
Return Values
If no error occurs, gethostname returns zero. Otherwise, it returns SOCKET_ERROR and a specific error code can be retrieved by calling WSAGetLastError.