Top Fields Methods
com.sun.jna.platform.win32

public Interface Winsock2

extends Library
Imports
com.sun.jna.Library, .Native, com.sun.jna.win32.W32APIOptions

Field Summary

Modifier and TypeField and Description
public static final Winsock2
Inherited from com.sun.jna.Library:
OPTION_ALLOW_OBJECTSOPTION_CALLING_CONVENTIONOPTION_CLASSLOADEROPTION_FUNCTION_MAPPEROPTION_INVOCATION_MAPPEROPTION_OPEN_FLAGSOPTION_STRING_ENCODINGOPTION_STRUCTURE_ALIGNMENTOPTION_SYMBOL_PROVIDEROPTION_TYPE_MAPPER

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

If no error occurs, gethostname returns zero. Otherwise, it returns SOCKET_ERROR and a specific error code can be retrieved by calling WSAGetLastError.
gethostname
(byte[]
A bytearray that receives the local host name.
name
,
int
The length, in bytes, of the buffer pointed to by the name parameter.
namelen
)

The gethostname function retrieves the standard host name for the local computer.

Field Detail

INSTANCEback to summary
public static final Winsock2 INSTANCE

Method Detail

gethostnameback to summary
public int gethostname(byte[] name, int namelen)

The gethostname function retrieves the standard host name for the local computer.

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.

The maximum length of the name returned in the buffer pointed to by the name parameter is dependent on the namespace provider.

If the gethostname function is used on a cluster resource on Windows Server 2008, Windows Server 2003, or Windows 2000 Server and the _CLUSTER_NETWORK_NAME_ environment variable is defined, then the value in this environment variable overrides the actual hostname and is returned. On a cluster resource, the _CLUSTER_NETWORK_NAME_ environment variable contains the name of the cluster.

The gethostname function queries namespace providers to determine the local host name using the SVCID_HOSTNAME GUID defined in the Svgguid.h header file. If no namespace provider responds, then the gethostname function returns the NetBIOS name of the local computer.

The maximum length, in bytes, of the string returned in the buffer pointed to by the name parameter is dependent on the namespace provider, but this string must be 256 bytes or less. So if a buffer of 256 bytes is passed in the name parameter and the namelen parameter is set to 256, the buffer size will always be adequate.

Parameters
name:byte[]

A bytearray that receives the local host name.

namelen:int

The length, in bytes, of the buffer pointed to by the name parameter.

Returns:int

If no error occurs, gethostname returns zero. Otherwise, it returns SOCKET_ERROR and a specific error code can be retrieved by calling WSAGetLastError.