Class WasiSocket

    • Method Detail

      • isConnected

        public boolean isConnected()
      • read

        public int read​(byte[] data,
                        int offset,
                        int len)
                 throws IOException
        Description copied from interface: ReadableIO
        Reads length bytes of data from this WasiIO into an array of bytes.
        Specified by:
        read in interface ReadableIO
        Parameters:
        data - the buffer into which the data is read.
        offset - the start offset in array b at which the data is written.
        len - the maximum number of bytes to read.
        Returns:
        the total number of bytes read into the buffer or -1 if there is no more data.
        Throws:
        IOException - if an I/O error occurs.
      • write

        public void write​(byte[] data,
                          int offset,
                          int len)
                   throws IOException
        Description copied from interface: WritableIO
        Writes length bytes from t he specified byte array starting at offset offset to this WasiIO.
        Specified by:
        write in interface WritableIO
        Parameters:
        data - the data to write.
        offset - the starting offset.
        len - the number of bytes to write.
        Throws:
        IOException - if an I/O error occurs.
      • close

        public void close()
                   throws IOException
        Description copied from interface: Closeable
        Closes 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:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Throws:
        IOException - if an I/O error occurs
      • available

        public int available()
                      throws IOException
        Retrieve the number of bytes available for reading on the socket.
        Specified by:
        available in interface ReadableIO
        Returns:
        the number of bytes available for reading on the socket.
        Throws:
        IOException - if an I/O error occurs.
      • getType

        public FileType getType()
        Description copied from interface: WasiIO
        Gets the WasiIO file descriptor type.
        Specified by:
        getType in interface WasiIO
        Returns:
        the WasiIO file descriptor type.
      • setNonBlocking

        public void setNonBlocking​(boolean nonBlockingMode)
        Description copied from interface: WasiSocketOpt
        Enable/disable the non blocking state on this WasiIO
        Specified by:
        setNonBlocking in interface ReadableIO
        Specified by:
        setNonBlocking in interface WasiSocketOpt
        Parameters:
        nonBlockingMode - whether to enable or disable the non-blocking socket option
      • setBroadcast

        public void setBroadcast​(boolean on)
                          throws IOException
        Description copied from interface: WasiSocketOpt
        Enable/disable the SO_BROADCAST socket option. Only meaningful for datagram sockets; stream sockets should ignore this call.
        Specified by:
        setBroadcast in interface WasiSocketOpt
        Parameters:
        on - whether to enable or disable broadcast
        Throws:
        IOException - if an I/O error occurs.
      • getBroadcast

        public boolean getBroadcast()
                             throws IOException
        Description copied from interface: WasiSocketOpt
        Get the SO_BROADCAST socket option. Only meaningful for datagram sockets; stream and server sockets always return false.
        Specified by:
        getBroadcast in interface WasiSocketOpt
        Returns:
        whether broadcast is enabled
        Throws:
        IOException - if an I/O error occurs.
      • setReuseAddress

        public void setReuseAddress​(boolean on)
                             throws IOException
        Description copied from interface: WasiSocketOpt
        Enable/disable the reuse address socket option.
        Specified by:
        setReuseAddress in interface WasiSocketOpt
        Parameters:
        on - whether to enable or disable the reuse address socket option
        Throws:
        IOException - if an I/O error occurs.
      • isNonBlocking

        public boolean isNonBlocking()
      • isReuseAddress

        public boolean isReuseAddress()
      • wasiShutdown

        public int wasiShutdown​(int how)
      • wasiSockReceive

        public int wasiSockReceive​(int iovecListPtr,
                                   int iovecLen,
                                   int riFlags,
                                   int nbRecvPtr,
                                   int roFlagsPtr,
                                   byte[] memory)
      • wasiSockSend

        public int wasiSockSend​(int iovecListPtr,
                                int iovecLen,
                                int nbSendPtr,
                                byte[] memory)
      • isConnectionReset

        public boolean isConnectionReset()
                                  throws IOException
        Check whether the connection been reset by the peer.
        Returns:
        connection reset status.
        Throws:
        IOException - if the socket is not connected or an I/O error occurs.
      • getWasiSSL

        @Nullable
        public WasiSSL getWasiSSL()
        Retrieve the associated WasiSSL context.
        Returns:
        the WasiSSL context.