Package EOorg.EOeolang.EOsys.Posix
Interface CStdLib
- All Superinterfaces:
com.sun.jna.Library
public interface CStdLib
extends com.sun.jna.Library
C standard library with unix syscalls.
- Since:
- 0.40
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.sun.jna.Library
com.sun.jna.Library.Handler -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intTCP connection family.static final CStdLibC STDLIB instance.static final intProtocol for TCP connection.static final intOpen flag for reading only.static final intOpen flag for reading and writing.static final intThe "Socket as stream" type.static final intStandard input file descriptor.static final intStandard output file descriptor.Fields inherited from interface com.sun.jna.Library
OPTION_ALLOW_OBJECTS, OPTION_CALLING_CONVENTION, OPTION_CLASSLOADER, OPTION_FUNCTION_MAPPER, OPTION_INVOCATION_MAPPER, OPTION_OPEN_FLAGS, OPTION_STRING_ENCODING, OPTION_STRUCTURE_ALIGNMENT, OPTION_SYMBOL_PROVIDER, OPTION_TYPE_MAPPER -
Method Summary
Modifier and TypeMethodDescriptionintaccept(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.intclose(int descriptor) Close file descriptor.intconnect(int sockfd, SockaddrIn addr, int addrlen) Connects to the server at the specified IP address and port.intdup(int descriptor) Duplicates file descriptor.intdup2(int descriptor, int other) Duplicates a file descriptor to another.Get environment variable.intgetpid()The "getpid" syscall.intgettimeofday(GettimeofdaySyscall.Timeval timeval, com.sun.jna.Pointer timezone) Get current time.intConvert IP string to binary form.intlisten(int sockfd, int backlog) Listen for incoming connections on socket.intThe "open" syscall.intread(int descriptor, byte[] buf, int size) Read bytes from file descriptor.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) Create an endpoint for communication.strerror(int errno) Convertserrnoto a human-readable string.intWrites given bytes buffer to file descriptor.
-
Field Details
-
INSTANCE
C STDLIB instance. -
STDIN_FILENO
static final int STDIN_FILENOStandard input file descriptor.- See Also:
-
STDOUT_FILENO
static final int STDOUT_FILENOStandard output file descriptor.- See Also:
-
O_RDONLY
static final int O_RDONLYOpen flag for reading only.- See Also:
-
O_RDWR
static final int O_RDWROpen flag for reading and writing.- See Also:
-
AF_INET
static final int AF_INETTCP connection family.- See Also:
-
SOCK_STREAM
static final int SOCK_STREAMThe "Socket as stream" type.- See Also:
-
IPPROTO_TCP
static final int IPPROTO_TCPProtocol for TCP connection.- See Also:
-
-
Method Details
-
dup
int dup(int descriptor) Duplicates file descriptor.- Parameters:
descriptor- Old file descriptor- Returns:
- New file descriptor
-
dup2
int dup2(int descriptor, int other) Duplicates a file descriptor to another.- Parameters:
descriptor- Old file descriptorother- New file descriptor- Returns:
- Duplicated file descriptor
-
getpid
int getpid()The "getpid" syscall.- Returns:
- Process ID.
-
open
The "open" syscall.- Parameters:
path- Path to file to openflags- Open flags- Returns:
- File descriptor
-
close
int close(int descriptor) Close file descriptor.- Parameters:
descriptor- File descriptor- Returns:
- Zero on success, -1 on error
-
write
Writes given bytes buffer to file descriptor.- Parameters:
descriptor- File descriptor.buf- Buffer.size- Number of bytes to be written.- Returns:
- Number of bytes was written.
-
read
int read(int descriptor, byte[] buf, int size) Read bytes from file descriptor.- Parameters:
descriptor- File descriptor.buf- Buffer.size- Number of bytes to be read.- Returns:
- Number of bytes was read.
-
getenv
Get environment variable.- Parameters:
name- Name of the variable- Returns:
- Name of the environment variable
-
gettimeofday
Get current time.- Parameters:
timeval- Timevaluetimezone- Timezone- Returns:
- Zero on success, -1 on error
-
socket
int socket(int domain, int type, int protocol) Create an endpoint for communication.- Parameters:
domain- Socket domaintype- Socket typeprotocol- Socket protocol- Returns:
- New socket descriptor on success, -1 on error
-
connect
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, -1 on error
-
bind
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
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.
-
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
-
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
-
inet_addr
Convert IP string to binary form.- Parameters:
address- IP address- Returns:
- IP address in binary form
-
strerror
Convertserrnoto a human-readable string.- Parameters:
errno- The error number- Returns:
- Error as string
-