Exemple #1
0
  public static void main(String args[]) throws Exception {
    String selfHostName = null;
    int selfPort = -1;
    String dstHostName = null;
    int dstPort = -1;
    if (!(args.length == 4)) {
      System.out.println("Usage: Sender self-hostname self-port dst-hostname dst-port");
      System.exit(1);
    }
    selfHostName = args[0];
    selfPort = Integer.parseInt(args[1]);
    dstHostName = args[2];
    dstPort = Integer.parseInt(args[3]);

    Peer p = Peer.getInstance(PeerId.newId());
    Transport<UdpLocator> t =
        p.newBaseTransport(new UdpLocator(new InetSocketAddress(selfHostName, selfPort)));
    t.send(new UdpLocator(new InetSocketAddress(dstHostName, dstPort)), "hello world");
    p.fin();
  }