C# UDP Socket taking time to send data to unknown IP
Posted
by
Mohsan
on Stack Overflow
See other posts from Stack Overflow
or by Mohsan
Published on 2010-12-31T07:06:57Z
Indexed on
2010/12/31
11:53 UTC
Read the original article
Hit count: 231
Hi.
i am sending data to UDP socket using this code
Socket udpClient = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Parse(obj.destAddress), obj.destPort);
byte[] buf = new byte[obj.length];
Array.Copy((byte[])obj.data, buf, obj.length);
int n = udpClient.SendTo(buf, ipEndPoint);
udpClient.Close();
this code works fine when IP exists in current network, but it takes 3-5 seconds when I send data to unknown IP address. This causes main application to hang for 3-5 seconds.. What could be the reason behind this problem..
© Stack Overflow or respective owner