Here is an example of using udpclient from .net

private static void UDPListener() { Task.Run(async () => { using (var udpClient = new UdpClient(11000)) { string loggingEvent = ""; while (true) { //IPEndPoint object will allow us to read datagrams sent from any source. var receivedResults = await udpClient.ReceiveAsync(); loggingEvent += Encoding.ASCII.GetString(receivedResults.Buffer); } } }); } 

I would like to understand how to use an analog from Java.Net.DatagramSocket.ReceiveAsync Alas, almost empty description If not an example, then the logic at least

  • I think that this function is just an asynchronous analogue of Receive . That is, takes the data in the pack . (The documentation describes the DatagramPacket pack argument, for some reason you don’t have it in the code.) - VladD
  • @VladD 'Task.Run (async () => {socket.Broadcast = true; byte [] buf = new byte [1024]; DatagramPacket packet = new DatagramPacket (buf, buf.Length); while (true) {await socket .ReceiveAsync (packet); if (packet! = Null) {message mess = new message (packet);}}}); ' - Alexey Kleandrov
  • Well, then, apparently, socket.ReceiveAsync(packet) starts a normal Task , which asynchronously waits for data, and delivers it to the packet . - VladD
  • @VladD Just something this data does not reach ( pastebin.com/Nci4dETy - Alexey Kleandrov
  • Maybe the package comes incomplete? Has the right, in theory. If this is the case, you need to collect data on the packets until it reaches as much as necessary. Try to log the arrival of information (or go to the debugger, if possible). - VladD

0