📄 class1.cs
字号:
using System;
using System.Text;
using System.Net;
using System.Net.Sockets;
namespace Wrox.ProCSharp.InternetAccess.UdpExample
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
UdpClient udpClient = new UdpClient();
string sendMsg = "Hello Echo Server";
byte [] sendBytes = Encoding.ASCII.GetBytes(sendMsg);
udpClient.Send(sendBytes, sendBytes.Length, "localhost", 7);
IPEndPoint endPoint = new IPEndPoint(0,0);
byte [] rcvBytes = udpClient.Receive(ref endPoint);
string rcvMessage = Encoding.ASCII.GetString(rcvBytes, 0, rcvBytes.Length);
// should print out "Hello Echo Server"
Console.WriteLine(rcvMessage);
Console.ReadLine();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -