示例#1
0
 public ReceiveFromData(
     ref byte[] buffer, int length, ref EndPoint endPoint,
     ref AsyncCallback onReceiveFrom, ref Socket socket, Socket ForwardSocket,
     UDP_helper UDP_helper
     )
 {
     this.onReceiveFrom = onReceiveFrom;
     this.buffer        = buffer;
     this.length        = length;
     this.endPoint      = endPoint;
     this.socket        = socket;
     this.ForwardSocket = ForwardSocket;
     this.UDP_helper    = UDP_helper;
 }
示例#2
0
        public static void Main(String[] args)
        {
            UDP_helper uh = new UDP_helper();

            if ("client".CompareTo(args[0]) == 0)
            {
                uh.sendToAddr = args[1];
                uh.sendToPort = int.Parse(args[2]);
            }
            else
            if ("server".CompareTo(args[0]) == 0)
            {
                uh.IsServer     = true;
                uh.listenOnPort = int.Parse(args[1]);
            }
            else
            if ("forward".CompareTo(args[0]) == 0)
            {
                uh.IsForward     = true;
                uh.listenOnPort  = int.Parse(args[1]);
                uh.forwardToAddr = args[2];
                uh.forwardToPort = int.Parse(args[3]);
                uh.listenWait    = 600;
            }
            else
            {
                Console.WriteLine("Usage: .exe sends multiple udp messages");
                Console.WriteLine("Usage: .exe client sendtoaddr sendtoport");
                Console.WriteLine("Usage: .exe server listenport");
                Console.WriteLine("Usage: .exe forward listenport forwardtoaddr forwardtoport");
                return;
            }
            Console.WriteLine(args[0]);

            uh.Run();
        }