0

I'm trying to create a Unity Program that will read from a socket that's sending UDP packets, and create in game changes accordingly. I was able to process data great with the UDPClient class, but then when I switched platform to Windows (I need it to be this because it's running on Hololens), the UDPClient was not recognized and I had to switch to the Windows.Networking API. I've found some examples online on people accepting UDP in Unity like these: https://forums.hololens.com/discussion/578/hololens-udp-server https://forums.hololens.com/discussion/7980/udp-communication-solved#latest

But even when I try them unedited (with the exception of ports and ip addresses), I get nothing when testing with my Packet Sender app. Can anyone point me in the right direction? I'm a little confused by these examples as they don't use the infinite loop I'm used to using in sockets, and instead use some sort of weird event handling.

  • What exception message are you getting? What IP and Port number are you using? A virus checker or firewall may be blocking the port number. The server must be started first and you need to connect to the server IP address and port number. – jdweng Aug 09 '17 at 17:03
  • @jdweng Thanks for your response. The last port I tried was 62804 and the IP address was just that of my local machine (I'm running my Packet Sender app on the same computer). I have to build and run the application every time I test, so I'm not able to check debug statements, but it seems like the only problem is that it's not picking up any packets. One thing worth noting may be that when I was trying this before with a typical UDPClient, it asked me for permission to access the network, but here it doesn't. Not sure how I can get that to come back up tho. – Snowday313 Aug 09 '17 at 17:13
  • Secure connections use multiple ports. Commands are sent on the port 465 or 587, but the actual data is sent on different ports. – jdweng Aug 09 '17 at 17:59
  • @jdweng What do you mean it's sent on different ports? It was my understanding that most of the arbitrary points beyond a certain number were free to use for listening and sending. – Snowday313 Aug 09 '17 at 19:43
  • Port number below 1000 are referred to a well-known port numbers with pre-assigned port numbers for each protocol. Port numbers above 1000 are free to be used as required. When you have a secure connection the initial connection is made on a pre-assigned port number. But then multiple port numbers are used for the actual traffic making it harder for hackers to intercept the traffic. For non secure protocols only one port number is used for a connection for sending and receiving. – jdweng Aug 09 '17 at 21:57

1 Answers1

0

UWP apps are not allowed to receive UDP packets from local host. You need to run your packet sender app on another machine. See this:

See this: UWP app doesn't receive UDP Datagram from a .NET desktop app on localhost

Sunius
  • 2,789
  • 18
  • 30
  • Thanks, I had no idea. Do you know why this is the case? – Snowday313 Aug 10 '17 at 15:41
  • Probably because "Microsoft said so". I don't think there's any other reason. – Sunius Aug 10 '17 at 15:44
  • I'm still seemingly unable to receive packets, even when sending them from another machine. Do I need to do anything special to make these guys talk? P.S. I'm doing this all in Unity. Is there another editor that could make working with all these stuff easier other than Visual Studio? – Snowday313 Aug 10 '17 at 16:47
  • There are several things to check. 1) Did you enable Internet Client & server capability in your app manifest? 2) Is the firewall blocking it by any chance? – Sunius Aug 11 '17 at 03:52
  • Thanks for all your help, Finally got this working by changing my binding method. – Snowday313 Aug 22 '17 at 19:59