Package EOorg.EOeolang.EOsys.Posix
Interface CStdLib
-
- All Superinterfaces:
com.sun.jna.Library
public interface CStdLib extends com.sun.jna.LibraryC standard library with unix syscalls.- Since:
- 0.40
-
-
Field Summary
Fields Modifier and Type Field Description static intAF_INETTCP connection family.static CStdLibINSTANCEC STDLIB instance.static intIPPROTO_TCPProtocol for TCP connection.static intO_RDONLYOpen flag for reading only.static intO_RDWROpen flag for reading and writing.static intSOCK_STREAMThe "Socket as stream" type.static intSTDIN_FILENOStandard input file descriptor.static intSTDOUT_FILENOStandard output file descriptor.
-
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.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.Stringgetenv(String name)Get environment variable.intgetpid()The "getpid" syscall.intgettimeofday(GettimeofdaySyscall.Timeval timeval, com.sun.jna.Pointer timezone)Get current time.intinet_addr(String address)Convert IP string to binary form.intlisten(int sockfd, int backlog)Listen for incoming connections on socket.intopen(String path, int flags)The "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.Stringstrerror(int errno)Convertserrnoto a human-readable string.intwrite(int descriptor, String buf, int size)Writes given bytes buffer to file descriptor.
-
-
-
Field Detail
-
INSTANCE
static final CStdLib INSTANCE
C STDLIB instance.
-
STDIN_FILENO
static final int STDIN_FILENO
Standard input file descriptor.- See Also:
- Constant Field Values
-
STDOUT_FILENO
static final int STDOUT_FILENO
Standard output file descriptor.- See Also:
- Constant Field Values
-
O_RDONLY
static final int O_RDONLY
Open flag for reading only.- See Also:
- Constant Field Values
-
O_RDWR
static final int O_RDWR
Open flag for reading and writing.- See Also:
- Constant Field Values
-
AF_INET
static final int AF_INET
TCP connection family.- See Also:
- Constant Field Values
-
SOCK_STREAM
static final int SOCK_STREAM
The "Socket as stream" type.- See Also:
- Constant Field Values
-
IPPROTO_TCP
static final int IPPROTO_TCP
Protocol for TCP connection.- See Also:
- Constant Field Values
-
-
Method Detail
-
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
int open(String path, int flags)
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
int write(int descriptor, String buf, int size)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
String getenv(String name)
Get environment variable.- Parameters:
name- Name of the variable- Returns:
- Name of the environment variable
-
gettimeofday
int gettimeofday(GettimeofdaySyscall.Timeval timeval, com.sun.jna.Pointer timezone)
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
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, -1 on error
-
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.
-
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
int inet_addr(String address)
Convert IP string to binary form.- Parameters:
address- IP address- Returns:
- IP address in binary form
-
strerror
String strerror(int errno)
Convertserrnoto a human-readable string.- Parameters:
errno- The error number- Returns:
- Error as string
-
-