I am trying to send data from my laptop to UDP server which communicates on port 30718. Data sending is correct, but when I want to receive response, program stucks on UdpClient.receive() method. i tried to sniff network with wireshark and it seem that response is delivered correctly, but c# will not receive it. Here is my code:
private void button1_Click(object sender, EventArgs e)
{
byte[] data = new byte[4];
data[0] = 0x00;
data[1] = 0x01;
data[2] = 0x00;
data[3] = 0xF6;
byte[] rcvPacket = new Byte[1024];
UdpClient client = new UdpClient();
IPAddress address = IPAddress.Parse("255.255.255.255");
client.EnableBroadcast = true;
client.Connect(address, 30718);
IPEndPoint remoteIPEndPoint = new IPEndPoint(IPAddress.Any, 0);
client.Send(data, 4);
rcvPacket = client.Receive(ref remoteIPEndPoint);
string rcvData = Encoding.ASCII.GetString(rcvPacket);
client.Close(); //close connection
}
And here is output from wireshark (second picture is response to broadcast request):
Does anybody have solution for fixing this problem? Thank you.