hi i need to write a program that connects to a device through Ethernet over the UDP protocal and get the data sent by the device. I tried using the .NET udp client methods but was unsuccessful. Can you guys help...this is my code....
static void Main(string[] args)
{
byte[] data = new byte[1024];
IPEndPoint ipep = new IPEndPoint(IPAddress.Parse("192.168.10.2"), 10001);
Socket server = new Socket(AddressFamily.InterNetwork,SocketType.Dgram, ProtocolType.Udp);
data = Encoding.ASCII.GetBytes("");
server.SendTo(data, data.Length, SocketFlags.None, ipep);
IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);
EndPoint tmpRemote = (EndPoint)sender;
while(true)
{
data = new byte[1024];
int recv = server.ReceiveFrom(data, ref tmpRemote);
Console.WriteLine("Message received from {0}:", tmpRemote.ToString());
Console.WriteLine(Encoding.ASCII.GetString(data, 0, recv));
file.Close();
}
Can any of you tell me whats wrong here....the ip address i have given is the ip of the device