Tuesday, July 1, 2008

passing message to sockets using C#

Make a reference to

using System.Net;
using System.Net.Sockets;

Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
try
{
IPAddress broadcast = IPAddress.Parse(ReceiverIpaddress);
byte[] sendbuf = Encoding.ASCII.GetBytes("Message to pass");
IPEndPoint ep = new IPEndPoint(broadcast, "Any Free port Number");
s.SendTo(sendbuf, ep);
}
catch
{}