T
T
tvsjke2016-07-05 10:16:35
C++ / C#
tvsjke, 2016-07-05 10:16:35

How to establish UDP connection with emulator under WIN CE?

There is a WIN CE emulator running on a virtual machine (the network is configured via NAT).
If the client is located on the emulator

try
{
      var client = new UdpClient();
      IPEndPoint ep = new IPEndPoint(IPAddress.Parse("10.0.1.252"), 11000); 
      client.Connect(ep);
      client.Send(new byte[] { 1, 2, 3, 4, 5 }, 5);
      var receivedData = client.Receive(ref ep);
      string msg = String.Format("receive data from " + ep.ToString());
      MessageBox.Show(msg);
}
catch (Exception ex)
{
      MessageBox.Show(ex.Message);
}

and servers on desktop
UdpClient udpServer = new UdpClient(11000);

while (true)
{
     var remoteEP = new IPEndPoint(IPAddress.Any, 11000);
     var data = udpServer.Receive(ref remoteEP); 

     string msg = String.Format("receive data from " + remoteEP.ToString());
     MessageBox.Show(msg);

     udpServer.Send(new byte[] { 1 }, 1, remoteEP); 
}

everything is working. If the server is placed on the emulator, then it will hang on the Receive timeout
. I suspect that something is wrong with the network settings (but what, does it work in the opposite direction?), while tcp works without problems in both directions
PS I understand that the question was asked incorrectly, because in udp, in fact, a connection is not established, but it was not possible to formulate it differently

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question