Package ej.wasi.io.socket
Class WasiServerSocket
- java.lang.Object
-
- ej.wasi.io.socket.WasiServerSocket
-
- All Implemented Interfaces:
WasiSocketOpt,WasiIO,WasiConstants,Closeable,AutoCloseable
public class WasiServerSocket extends Object implements WasiSocketOpt, WasiIO, WasiConstants
-
-
Field Summary
-
Fields inherited from interface ej.wasi.WasiConstants
AF_INET, AF_INET6, BLOCKING_CONNECT_TIMEOUT, BUFFERED_INPUT_STREAM_SIZE, CLOCK_MONOTONIC, CLOCK_REALTIME, DIRENT_COOKIE_OFFSET, DIRENT_ENTRY_NAME_LENGTH_OFFSET, DIRENT_FILE_TYPE_OFFSET, DIRENT_INODE_OFFSET, DIRENT_SIZE, ERRNO_ACCES, ERRNO_ADDRINUSE, ERRNO_ADDRNOTAVAIL, ERRNO_AFNOSUPPORT, ERRNO_AGAIN, ERRNO_BADF, ERRNO_CONNREFUSED, ERRNO_EXIST, ERRNO_FAULT, ERRNO_HOSTUNREACH, ERRNO_INPROGRESS, ERRNO_INTR, ERRNO_INVAL, ERRNO_IO, ERRNO_ISCONN, ERRNO_ISDIR, ERRNO_MSGSIZE, ERRNO_NAMETOOLONG, ERRNO_NOENT, ERRNO_NOMEM, ERRNO_NOSYS, ERRNO_NOTCONN, ERRNO_NOTDIR, ERRNO_NOTEMPTY, ERRNO_NOTSOCK, ERRNO_NOTSUP, ERRNO_OVERFLOW, ERRNO_SPIPE, ERRNO_SUCCESS, EVENT_AVAILABLE_BYTE_OFFSET, EVENT_ERROR_OFFSET, EVENT_EVENT_TYPE_OFFSET, EVENT_READ_WRITE_HANGUP_OFFSET, EVENT_SIZE, EVENT_USER_DATA_OFFSET, FDFLAGS_APPEND_MASK, FDFLAGS_NON_BLOCK_MASK, FDSTAT_BASE_RIGHTS_OFFSET, FDSTAT_FILE_TYPE_OFFSET, FDSTAT_FLAGS_OFFSET, FDSTAT_INHERITING_RIGHTS_OFFSET, FILESTAT_FILESIZE_OFFSET, FILESTAT_FILETYPE_OFFSET, FILESTAT_INODE_OFFSET, FILESTAT_LAST_MODIFIED_TIME_OFFSET, IFF_LOOPBACK, IFF_RUNNING, IFF_UP, IOVEC_BUFFER_INDEX, IOVEC_BUFFER_LENGTH_INDEX, IOVEC_SIZE, IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, IP_MULTICAST_IF, IP_MULTICAST_LOOP, IP_MULTICAST_TTL, IP_TTL, IPPROTO_IP, IPPROTO_IPV6, IPv4AddressSize, IPV6_JOIN_GROUP, IPV6_LEAVE_GROUP, IPV6_MULTICAST_HOPS, IPV6_MULTICAST_IF, IPV6_MULTICAST_LOOP, IPV6_UNICAST_HOPS, IPv6AddressSize, LOOKUPFLAGS_SYMLINK_FOLLOW_MASK, MILLIS_TO_NANO, NON_BLOCKING_TIMEOUT, OFLAGS_CREAT_MASK, OFLAGS_DIRECTORY_MASK, OFLAGS_EXCL_MASK, OFLAGS_TRUNC_MASK, POLLING_TIMEOUT, PREOPENTYPE_DIR, PREOPENTYPE_UNKNOWN, PRESTAT_PREOPEN_DIRNAME_OFFSET, PRESTAT_PREOPEN_TAG_OFFSET, RIFLAGS_MSG_PEEK_MASK, RIFLAGS_WAITALL_MASK, RIGHTS_ALL, RIGHTS_DIR, SDFLAGS_READ, SDFLAGS_WRITE, SO_BROADCAST, SO_RCVBUF, SO_REUSEADDR, SO_SNDBUF, SOCK_CLOEXEC, SOCK_NONBLOCK, SOCKET_LEVEL, UDP_PEEK_BUFFER_MAX_SIZE
-
-
Constructor Summary
Constructors Constructor Description WasiServerSocket()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WasiSocketaccept()voidbind(InetSocketAddress addr)booleancanAccept()voidclose()Closes this stream and releases any system resources associated with it.booleangetBroadcast()Get the SO_BROADCAST socket option.SocketAddressgetLocalSocketAddress()intgetReceiveBufferSize()Get the receive buffer size (SO_RCVBUF).intgetSendBufferSize()Get the send buffer size (SO_SNDBUF).FileTypegetType()Gets the WasiIO file descriptor type.voidlisten(int backlog)voidsetBroadcast(boolean on)Enable/disable the SO_BROADCAST socket option.voidsetNonBlocking(boolean nonBlocking)Enable/disable the non blocking state on this WasiIOvoidsetReceiveBufferSize(int size)Set the receive buffer size (SO_RCVBUF).voidsetReuseAddress(boolean on)Enable/disable the reuse address socket option.voidsetSendBufferSize(int size)Set the send buffer size (SO_SNDBUF).
-
-
-
Constructor Detail
-
WasiServerSocket
public WasiServerSocket() throws IOException- Throws:
IOException
-
-
Method Detail
-
bind
public void bind(InetSocketAddress addr) throws IOException
- Throws:
IOException
-
listen
public void listen(int backlog) throws IOException- Throws:
IOException
-
accept
@Nullable public WasiSocket accept() throws IOException
- Throws:
IOException
-
getLocalSocketAddress
@Nullable public SocketAddress getLocalSocketAddress()
-
close
public void close() throws IOExceptionDescription copied from interface:CloseableCloses this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- if an I/O error occurs
-
canAccept
public boolean canAccept() throws IOException- Throws:
IOException
-
getType
public FileType getType()
Description copied from interface:WasiIOGets the WasiIO file descriptor type.
-
setNonBlocking
public void setNonBlocking(boolean nonBlocking) throws IOExceptionDescription copied from interface:WasiSocketOptEnable/disable the non blocking state on this WasiIO- Specified by:
setNonBlockingin interfaceWasiSocketOpt- Parameters:
nonBlocking- whether to enable or disable the non-blocking socket option- Throws:
IOException- if an I/O error occurs.
-
setBroadcast
public void setBroadcast(boolean on) throws IOExceptionDescription copied from interface:WasiSocketOptEnable/disable the SO_BROADCAST socket option. Only meaningful for datagram sockets; stream sockets should ignore this call.- Specified by:
setBroadcastin interfaceWasiSocketOpt- Parameters:
on- whether to enable or disable broadcast- Throws:
IOException- if an I/O error occurs.
-
getBroadcast
public boolean getBroadcast() throws IOExceptionDescription copied from interface:WasiSocketOptGet the SO_BROADCAST socket option. Only meaningful for datagram sockets; stream and server sockets always returnfalse.- Specified by:
getBroadcastin interfaceWasiSocketOpt- Returns:
- whether broadcast is enabled
- Throws:
IOException- if an I/O error occurs.
-
setReuseAddress
public void setReuseAddress(boolean on) throws IOExceptionDescription copied from interface:WasiSocketOptEnable/disable the reuse address socket option.- Specified by:
setReuseAddressin interfaceWasiSocketOpt- Parameters:
on- whether to enable or disable the reuse address socket option- Throws:
IOException- if an I/O error occurs.
-
setReceiveBufferSize
public void setReceiveBufferSize(int size) throws IOExceptionDescription copied from interface:WasiSocketOptSet the receive buffer size (SO_RCVBUF).- Specified by:
setReceiveBufferSizein interfaceWasiSocketOpt- Parameters:
size- the buffer size in bytes- Throws:
IOException- if an I/O error occurs.
-
getReceiveBufferSize
public int getReceiveBufferSize() throws IOExceptionDescription copied from interface:WasiSocketOptGet the receive buffer size (SO_RCVBUF).- Specified by:
getReceiveBufferSizein interfaceWasiSocketOpt- Returns:
- the buffer size in bytes
- Throws:
IOException- if an I/O error occurs.
-
setSendBufferSize
public void setSendBufferSize(int size) throws IOExceptionDescription copied from interface:WasiSocketOptSet the send buffer size (SO_SNDBUF).- Specified by:
setSendBufferSizein interfaceWasiSocketOpt- Parameters:
size- the buffer size in bytes- Throws:
IOException- if an I/O error occurs.
-
getSendBufferSize
public int getSendBufferSize() throws IOExceptionDescription copied from interface:WasiSocketOptGet the send buffer size (SO_SNDBUF).- Specified by:
getSendBufferSizein interfaceWasiSocketOpt- Returns:
- the buffer size in bytes
- Throws:
IOException- if an I/O error occurs.
-
-