Created
October 17, 2017 06:41
-
-
Save petecleary/e150923584a95f419300380523db05cf to your computer and use it in GitHub Desktop.
How to send a UDP message in C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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