string mHost="hostname";
int mPort="1111";
string mMessage="message";
try {
mClient=new UdpClient();
IPAddress mIPAddress=Dns.GetHostEntry(mHost).AddressList[0];
mRemoteEndPoint=new IPEndPoint(mIPAddress, mPort);
mClient.Connect(mRemoteEndPoint);
}
catch(Exception mEX) {
MessageBox.Show(mEX.Message);
}
mClient.Send(Encoding.Unicode.GetBytes(mMessage), Encoding.Unicode.GetBytes(mMessage).Length);
Wednesday, February 06, 2008
Sending UDP messages in C#
How to send a UDP message to a UDP server in C#.
Subscribe to:
Posts (Atom)