S
Sin Jeong-hun
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,
ProtocolType.Udp);
//ServerPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"),
50000); //<---(1) This has no effect.
ServerPoint = new IPEndPoint(IPAddress.Parse("100.1.2.3"),
50000); //<---(2) This works.
int sent = s.SendTo(new byte[100], ServerPoint);
Debug.WriteLine("===> " + sent + " bytes sent");
After two hours of head scratching, I'm finally asking here. I tried
to test a simple UDP server / client applications on my PC. But I
couldn't send a UDP packet to the local (the same pc where the sending
application is on) pc. If I set the ServerPoint with line (1), even
though SendTo returns 100, I cannot see an outgoing UDP packet on the
Ethereal. Only if I change the destination address to another PC like
line (2), does a UDP packet go out. What is wrong with the code above?
Of course I don't think there is a limitation as two local
applications cannot communicate with UDP, since I did that once with
Java a few years ago.
I tried UdpClient (of course I didn't use the same port for both
client/server), my public IP address instead of 127.0.0.1,
IPAddress.Loopback, Dns.GetHostByName("localhost"), etc but the result
was the same.
Thank you for any hint.
ProtocolType.Udp);
//ServerPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"),
50000); //<---(1) This has no effect.
ServerPoint = new IPEndPoint(IPAddress.Parse("100.1.2.3"),
50000); //<---(2) This works.
int sent = s.SendTo(new byte[100], ServerPoint);
Debug.WriteLine("===> " + sent + " bytes sent");
After two hours of head scratching, I'm finally asking here. I tried
to test a simple UDP server / client applications on my PC. But I
couldn't send a UDP packet to the local (the same pc where the sending
application is on) pc. If I set the ServerPoint with line (1), even
though SendTo returns 100, I cannot see an outgoing UDP packet on the
Ethereal. Only if I change the destination address to another PC like
line (2), does a UDP packet go out. What is wrong with the code above?
Of course I don't think there is a limitation as two local
applications cannot communicate with UDP, since I did that once with
Java a few years ago.
I tried UdpClient (of course I didn't use the same port for both
client/server), my public IP address instead of 127.0.0.1,
IPAddress.Loopback, Dns.GetHostByName("localhost"), etc but the result
was the same.
Thank you for any hint.