0

Hello everybody!
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.

So I want to know, how to send a packet to a server.

Thank you!

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by mcriscolo
0

I'm assuming you mean "UDP".

byte[] data = new byte[1024];
string sData = "<the packet data - fill with what you want>";
IPEndPoint ep = new IPEndPoint("127.0.0.1", 8000); // change to the IP address and port of your server

Socket gameServer = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
data = Encoding.ASCII.GetBytes(sData);
gameServer.SendTo(data, data.Length, SocketFlags.None, ep);

Of course, there are all sorts of things that can go wrong - you need to put in exception handling to make sure you catch any issues.

Now, if your data is not string data and is already binary, well, you can just serialize the data into the byte array and send it along.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.