FileDocCategorySizeDatePackage
BigPacket.javaAPI DocExample1128Sun Dec 12 10:53:36 GMT 2004None

BigPacket

public class BigPacket extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

    
    int port = 9;

    String hostname = "localhost";
    if (args.length > 0) hostname = args[0];
    if (args.length > 1) port = Integer.parseInt(args[1]);

    try {
      String s = "";
      for (int i = 0; i < 8192*2; i += 74) {
        s += "6789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{\r\n";
      }
      byte[] data = s.getBytes("ASCII");
      InetAddress host = InetAddress.getByName(hostname);
      DatagramSocket ds = new DatagramSocket();
      ds.connect(host, port);
      ds.setSoTimeout(15000);
      ds.setReceiveBufferSize(32768);
      ds.setSendBufferSize(32768);
      System.out.println(ds.getReceiveBufferSize());
      System.out.println(ds.getSendBufferSize());
      DatagramPacket incoming = new DatagramPacket(new byte[65507], 65507);
      DatagramPacket outgoing = new DatagramPacket(data, data.length);
      ds.send(outgoing);      
    }
    catch (IOException e) {
      System.err.println(e); 
    }