Interface ISocketWrapper

All Superinterfaces:
AutoCloseable, Closeable

public interface ISocketWrapper extends Closeable
This is the public interface to ISocketWrapper, whose purpose is to make our lives easier when working with Socket. Created to provide better testing access
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
    Send the data in the outgoing buffer into the socket.
    The hostname of the server, as set in the configuration file of key HOST_NAME in Constants.hostName
    Returns this socket's input stream for more granular access
    int
    Get the port of the server
    Returns a string of the remote host address without port
    Returns a SocketAddress, which includes the client's address and port
     
    void
    send(byte[] bodyContents)
    Simply send the bytes on the socket, simple as that.
    void
    send(byte[] bodyContents, int off, int len)
     
    void
    send(int b)
     
    void
    send(String msg)
    Convert the provided string value into bytes using the default charset, and send on the socket.
    void
    Sends a line of text, with carriage-return and line-feed appended to the end, required for the HTTP protocol.
  • Method Details

    • send

      void send(String msg) throws IOException
      Convert the provided string value into bytes using the default charset, and send on the socket.
      Throws:
      IOException
    • send

      void send(byte[] bodyContents) throws IOException
      Simply send the bytes on the socket, simple as that.
      Throws:
      IOException
    • send

      void send(byte[] bodyContents, int off, int len) throws IOException
      Throws:
      IOException
    • send

      void send(int b) throws IOException
      Throws:
      IOException
    • sendHttpLine

      void sendHttpLine(String msg) throws IOException
      Sends a line of text, with carriage-return and line-feed appended to the end, required for the HTTP protocol.
      Throws:
      IOException
    • getLocalPort

      int getLocalPort()
      Get the port of the server
    • getRemoteAddrWithPort

      SocketAddress getRemoteAddrWithPort()
      Returns a SocketAddress, which includes the client's address and port
    • getRemoteAddr

      String getRemoteAddr()
      Returns a string of the remote host address without port
    • getServerType

      HttpServerType getServerType()
    • close

      void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • getInputStream

      InputStream getInputStream()
      Returns this socket's input stream for more granular access
    • getHostName

      String getHostName()
      The hostname of the server, as set in the configuration file of key HOST_NAME in Constants.hostName
    • flush

      void flush() throws IOException
      Send the data in the outgoing buffer into the socket.
      Throws:
      IOException