Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending UDP Packet in C#

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!

like image 869
DOminik Avatar asked Apr 14 '10 13:04

DOminik


People also ask

Can you use Send with UDP?

UDP sockets can be connected or unconnected - in the first case send should be used and in the second sendto . This does not affect the protocol used, i.e. it still is unreliable UDP. It only affects where the destination is taken from: from the socket or given as argument.

How do I create a UDP connection?

To use UDP, you must use the %New()Opens in a new tab method to create a UDP socket object. This object instance is then used to send, receive, and reply to packet transmissions. Both the port number and the host address are optional.

What is UDP in C?

UDP is a connection-less protocol that, unlike TCP, does not require any handshaking prior to sending or receiving data, which simplifies its implementation.

Can UDP client communicate with TCP server?

No, you can't have a TCP server communicating with UDP clients.


1 Answers

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); 
like image 145
nos Avatar answered Sep 21 '22 07:09

nos