Exemplo n.º 1
0
 /// <summary>
 /// 设置基本配置
 /// </summary>
 /// <param name="receiveBufferSize">用于每个套接字I/O操作的缓冲区大小(接收端)</param>
 /// <param name="ip">ip或者域名</param>
 /// <param name="port">端口</param>
 public UdpClient(int receiveBufferSize, string ip, int port)
 {
     client            = new UdpClients(receiveBufferSize);
     client.OnReceive += OnReceive;
     client.OnSend    += OnSend;
     client.Start(ip, port);
     Console.WriteLine("Udp已启动,端口:" + port);
 }
Exemplo n.º 2
0
 static void Main(string[] args)
 {
     udpclient = new UdpClients(1024);
     udpclient.Start("127.0.0.1", 6666);
     udpclient.OnReceive += UdpServer_OnReceive;
     udpclient.OnSend    += UdpServer_OnSend;
     for (int i = 0; i < 10; i++)
     {
         udpclient.Send(new byte[] { 65, 96 }, 0, 2);
     }
     Console.Read();
 }
Exemplo n.º 3
0
 static void Main(string[] args)
 {
     udpclient = new UdpClients(1024);
     udpclient.Start("127.0.0.1", 6666);
     udpclient.OnReceive += UdpServer_OnReceive;
     udpclient.OnSend    += UdpServer_OnSend;
     byte[] arg2 = Encoding.UTF8.GetBytes("fdsafdsafdsafdsafdasfdsafffdsafdsafdsafdsafdasfdsaffdsafdsafdsafdsafdasfdsaffdsafaaadsafdsafdsafdasfdsaffdsafdsafdsafdsafdasfdsafdsafdsafdsafdsafdasfdsaffdsafdsafdsafdsafdasfdsaffdsafdsafdsafdsafdasfdsaf");
     for (int i = 0; i < int.MaxValue; i++)
     {
         udpclient.Send(arg2, 0, arg2.Length);
         Thread.Sleep(1);
     }
     Console.Read();
 }
Exemplo n.º 4
0
 public NetUdpClient(int buffersize, int threads)
 {
     udpClient            = new UdpClients(buffersize);
     udpClient.OnSend    += OnSendInternal;
     udpClient.OnReceive += OnReceiveInternal;
 }