forked from tmoonlight/NSmartProxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
31 lines (28 loc) · 1001 Bytes
/
Program.cs
File metadata and controls
31 lines (28 loc) · 1001 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace UdpServer
{
class Program
{
const int listenPort = 30001;
static async Task Main(string[] args)
{
Console.WriteLine("*** Udp Sever ***");
UdpClient udpClient = new UdpClient(listenPort);
//UdpClient udpClient = new UdpClient(9999);
int count = 5;
while (count > 0)
{
var udpReceiveResult = await udpClient.ReceiveAsync();
var str = Encoding.ASCII.GetString(udpReceiveResult.Buffer);
var receiveStr = Encoding.ASCII.GetBytes("hello" + str);
await udpClient.SendAsync(receiveStr, receiveStr.Length, udpReceiveResult.RemoteEndPoint);
Console.WriteLine($"[{udpReceiveResult.RemoteEndPoint.ToString()}]{str}");
count--;
}
//Console.WriteLine("Hello World!");
}
}
}