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 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