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.StdCallLibrary
Interface definitions forWS2_32.dll
.- Since:
- 0.40
-
-
Field Summary
Fields Modifier and Type Field Description static int
AF_INET
The Internet Protocol version 4 (IPv4) address family.static Winsock
INSTANCE
Instance.static int
INVALID_SOCKET
Invalid socket descriptor.static int
IPPROTO_TCP
The Transmission Control Protocol (TCP).static int
SOCK_STREAM
A socket type that provides sequenced, reliable, two-way, connection-based byte streams with an OOB data transmission mechanism.static int
SOCKET_ERROR
Status returned on errors with socket.static short
WINSOCK_VERSION_2_2
Winsock version.static int
WSAEINVAL
Error 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 int
accept(int sockfd, SockaddrIn addr, com.sun.jna.ptr.IntByReference addrlen)
Accept connection on socket.int
bind(int sockfd, SockaddrIn addr, int addrlen)
Assigns the address specified byaddr
to the socket referred to by the file descriptorsockfd
.int
closesocket(int socket)
Closes a socket.int
connect(int sockfd, SockaddrIn addr, int addrlen)
Connects to the server at the specified IP address and port.int
listen(int sockfd, int backlog)
Listen for incoming connections on socket.int
recv(int sockfd, byte[] buf, int len, int flags)
Receive a message from a socket.int
send(int sockfd, byte[] buf, int len, int flags)
Send a message to a socket.int
socket(int domain, int type, int protocol)
Creates a socket.int
WSACleanup()
Stops usage of Winsock 2 by DLL.int
WSAGetLastError()
Retrieve the last error from winsock.int
WSAStartup(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 byaddr
to 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.
-
-