Package EOorg.EOeolang.EOsys.Win32
Interface Winsock
-
- All Superinterfaces:
com.sun.jna.AltCallingConvention,com.sun.jna.Library,com.sun.jna.win32.StdCall,com.sun.jna.win32.StdCallLibrary
public interface Winsock extends com.sun.jna.win32.StdCallLibraryInterface definitions forWS2_32.dll.- Since:
- 0.40
-
-
Field Summary
Fields Modifier and Type Field Description static intAF_INETThe Internet Protocol version 4 (IPv4) address family.static WinsockINSTANCEInstance.static intINVALID_SOCKETInvalid socket descriptor.static intIPPROTO_TCPThe Transmission Control Protocol (TCP).static intSOCK_STREAMA socket type that provides sequenced, reliable, two-way, connection-based byte streams with an OOB data transmission mechanism.static intSOCKET_ERRORStatus returned on errors with socket.static shortWINSOCK_VERSION_2_2Winsock version.static intWSAEINVALError code that indicates that an invalid argument was passed to the function.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intaccept(int sockfd, SockaddrIn addr, com.sun.jna.ptr.IntByReference addrlen)Accept connection on socket.intbind(int sockfd, SockaddrIn addr, int addrlen)Assigns the address specified byaddrto the socket referred to by the file descriptorsockfd.intclosesocket(int socket)Closes a socket.intconnect(int sockfd, SockaddrIn addr, int addrlen)Connects to the server at the specified IP address and port.intlisten(int sockfd, int backlog)Listen for incoming connections on socket.intrecv(int sockfd, byte[] buf, int len, int flags)Receive a message from a socket.intsend(int sockfd, byte[] buf, int len, int flags)Send a message to a socket.intsocket(int domain, int type, int protocol)Creates a socket.intWSACleanup()Stops usage of Winsock 2 by DLL.intWSAGetLastError()Retrieve the last error from winsock.intWSAStartup(short version, WSAStartupFuncCall.WSAData data)Initializes winsock usage by DLL process.
-
-
-
Field Detail
-
INSTANCE
static final Winsock INSTANCE
Instance.
-
WSAEINVAL
static final int WSAEINVAL
Error code that indicates that an invalid argument was passed to the function.- See Also:
- Constant Field Values
-
WINSOCK_VERSION_2_2
static final short WINSOCK_VERSION_2_2
Winsock version.- See Also:
- Constant Field Values
-
AF_INET
static final int AF_INET
The Internet Protocol version 4 (IPv4) address family.- See Also:
- Constant Field Values
-
SOCK_STREAM
static final int SOCK_STREAM
A socket type that provides sequenced, reliable, two-way, connection-based byte streams with an OOB data transmission mechanism. This socket type uses the TCP for the Internet address family (AF_INET or AF_INET6).- See Also:
- Constant Field Values
-
IPPROTO_TCP
static final int IPPROTO_TCP
The Transmission Control Protocol (TCP). This is a possible value when the af parameter is AF_INET or AF_INET6 and the type parameter is SOCK_STREAM.- See Also:
- Constant Field Values
-
INVALID_SOCKET
static final int INVALID_SOCKET
Invalid socket descriptor.- See Also:
- Constant Field Values
-
SOCKET_ERROR
static final int SOCKET_ERROR
Status returned on errors with socket.- See Also:
- Constant Field Values
-
-
Method Detail
-
WSAStartup
int WSAStartup(short version, WSAStartupFuncCall.WSAData data)Initializes winsock usage by DLL process.- Parameters:
version- Highest Windows socket specification version.data- Data with info about socket structure- Returns:
- Zero on success, error code on error.
-
WSACleanup
int WSACleanup()
Stops usage of Winsock 2 by DLL.- Returns:
- Zero on success, SOCKET_ERROR on error.
-
socket
int socket(int domain, int type, int protocol)Creates a socket.- Parameters:
domain- Socket domaintype- Socket typeprotocol- Socket protocol- Returns:
- Socket descriptor
-
closesocket
int closesocket(int socket)
Closes a socket.- Parameters:
socket- Socket descriptor- Returns:
- Zero on success, otherwise, a value of SOCKET_ERROR is returned.
-
connect
int connect(int sockfd, SockaddrIn addr, int addrlen)Connects to the server at the specified IP address and port.- Parameters:
sockfd- Socket descriptoraddr- Address structureaddrlen- The size of the address structure- Returns:
- Zero on success, otherwise, a value of SOCKET_ERROR is returned.
-
bind
int bind(int sockfd, SockaddrIn addr, int addrlen)Assigns the address specified byaddrto the socket referred to by the file descriptorsockfd.- Parameters:
sockfd- Socket descriptoraddr- Address structureaddrlen- The size of the address structure- Returns:
- Zero on success, -1 on error
-
listen
int listen(int sockfd, int backlog)Listen for incoming connections on socket.- Parameters:
sockfd- Socket descriptorbacklog- Specifies the queue length for completely established sockets waiting to be accepted- Returns:
- Zero on success, -1 on error
-
accept
int accept(int sockfd, SockaddrIn addr, com.sun.jna.ptr.IntByReference addrlen)Accept connection on socket.- Parameters:
sockfd- Socket descriptoraddr- Address structureaddrlen- The size of the address structure- Returns:
- On success, file descriptor for the accepted socket (a nonnegative integer) is returned. On error, -1 is returned.
-
send
int send(int sockfd, byte[] buf, int len, int flags)Send a message to a socket.- Parameters:
sockfd- Socket descriptorbuf- Byte buffer to store sent byteslen- Size of sent dataflags- Flags- Returns:
- The number of sent bytes on success, -1 on error
-
recv
int recv(int sockfd, byte[] buf, int len, int flags)Receive a message from a socket.- Parameters:
sockfd- Socket descriptorbuf- Byte buffer to store received byteslen- Size of received dataflags- Flags- Returns:
- The number of received bytes on success, -1 on error
-
WSAGetLastError
int WSAGetLastError()
Retrieve the last error from winsock.- Returns:
- The code of the last winsock error.
-
-