Пример #1
0
  public static void main(String args[]) throws IOException, SQLException, ClassNotFoundException {

    final String host = "192.168.16.146";
    final int portNumber = 10010;

    System.out.println("Creating socket to '" + host + "' on port " + portNumber);
    Socket socket = new Socket(host, portNumber);

    final NhrDataService nhrConnection =
        new NhrConnectionBuilder(socket)
            .withInputBufferedReader(
                new BufferedReader(new InputStreamReader(socket.getInputStream())))
            .withDataInputStream(new DataInputStream(socket.getInputStream()))
            .withDataOutputStream(new DataOutputStream(socket.getOutputStream()))
            .build();

    ReceiverThread receiverThread = new ReceiverThread();
    receiverThread.setNhrConnection(nhrConnection);
    receiverThread.start();

    SenderThread senderThread = new SenderThread();
    senderThread.setNhrConnection(nhrConnection);
    senderThread.start();
  }