Class NetworkConnector

java.lang.Object
jp.co.sanei_elec.printerlibrary.api.connectivity.AbstractConnector
jp.co.sanei_elec.printerlibrary.api.connectivity.NetworkConnector

public class NetworkConnector extends AbstractConnector
This class implements a network connector to remote host.
  • Constructor Details

    • NetworkConnector

      public NetworkConnector(android.content.Context context, String host, int port)
      Creates a NetworkConnector from a hostname and a port number.
      Parameters:
      context - the context of network connector.
      host - the host name.
      port - the port address.
  • Method Details

    • getHost

      public String getHost()
      Gets the host name.
      Returns:
      the host name.
    • getPort

      public int getPort()
      Gets the port number.
      Returns:
      the port number.
    • connect

      public void connect() throws IOException
      Connects this connector to the specified remote network host.
      Specified by:
      connect in class AbstractConnector
      Throws:
      IOException - if socket is already connected or an error occurs while connecting.
    • close

      public void close() throws IOException
      Closes this network connector and releases any system resources associated with it.
      Specified by:
      close in class AbstractConnector
      Throws:
      IOException - if an I/O error occurs.
    • getInputStream

      public InputStream getInputStream() throws IOException
      Return an input stream to read data from this connector.
      Specified by:
      getInputStream in class AbstractConnector
      Returns:
      the byte-oriented input stream.
      Throws:
      IOException - if an I/O error occurs.
    • getOutputStream

      public OutputStream getOutputStream() throws IOException
      Return an output stream to write data into this connector.
      Specified by:
      getOutputStream in class AbstractConnector
      Returns:
      the byte-oriented output stream.
      Throws:
      IOException - if an I/O error occurs.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object