class Connector {

  static ConnectDetails read(InputStream in) throws CommunicationException {

    try {
      final ObjectInputStream objectInputStream = new ObjectInputStream(in);
      final ConnectionType type =
        (ConnectionType) objectInputStream.readObject();
      final Address address = (Address) objectInputStream.readObject();
      return new ConnectDetails(type, address);
    }
    catch (IOException e) {
      throw new CommunicationException("Could not read address details", e);
    }
    catch (ClassNotFoundException e) {
      throw new CommunicationException("Could not read address details", e);
    }
  }

  public  Connector(String hostString,
                   int port,
                   ConnectionType connectionType);

}