Skip to content

Instantly share code, notes, and snippets.

@petecleary
Created October 17, 2017 06:41
Show Gist options
  • Save petecleary/e150923584a95f419300380523db05cf to your computer and use it in GitHub Desktop.
Save petecleary/e150923584a95f419300380523db05cf to your computer and use it in GitHub Desktop.
How to send a UDP message in C#
using System.Net;
using System.Net.Sockets;
string hostName = "192.168.1.1";
int port = 5000;
string msg = "Hello";
UdpClient udpClient = new UdpClient(hostName, port);
Byte[] sendBytes = Encoding.ASCII.GetBytes(msg);
udpClient.Send(sendBytes, sendBytes.Length);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment