在 C# 中发送 UDP 数据包 [英] Sending UDP Packet in C#
本文介绍了在 C# 中发送 UDP 数据包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个游戏服务器 (WoW).我希望我的玩家将我的自定义补丁下载到游戏中.我已经完成了一个检查更新/下载内容的程序.如果玩家拥有我的所有补丁,我希望我的程序将数据包发送到我的游戏服务器.我不需要来自服务器的任何响应,它会处理它,但它是另一回事.
I have a game server (WoW). I want my players to download my custom patches to the game. I've done a program that checks for update/downloading things. I want my program to send a packet to my game server if player have all my patches. I dont need any response from the server, it will handle it, but its another story.
所以我想知道,如何将数据包发送到服务器.
谢谢!
推荐答案
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,
ProtocolType.Udp);
IPAddress serverAddr = IPAddress.Parse("192.168.2.255");
IPEndPoint endPoint = new IPEndPoint(serverAddr, 11000);
string text = "Hello";
byte[] send_buffer = Encoding.ASCII.GetBytes(text );
sock.SendTo(send_buffer , endPoint);
这篇关于在 C# 中发送 UDP 数据包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文