Hi All,
I visited a lot of forums, posts and I cannot end up with working hololens app which communicate over UDP port. Problem which I get now is that app wroten in UNITY works greate in Unity Test Emulator, it receives communication and it's just great.
But when I export project to Visual Studio and transfer up to Hololens Device it just start up and it's not getting any signals... App behaves like there is no incoming communication on UDP port but I send good messages to valid hololens IP address
Any idea where I can have problem ? Below code which I use:
using UnityEngine;
using System;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;
public class UDPconnector : MonoBehaviour
{
Thread receiveThread;
UdpClient client;
int port = 12345;
public string lastReceivedUDPPacket = "";
public void Start()
{
init();
}
void OnGUI()
{
Rect rectObj = new Rect(40, 10, 200, 400);
GUIStyle style = new GUIStyle();
style.alignment = TextAnchor.UpperLeft;
GUI.Box(rectObj, "\nMessage: \n" + lastReceivedUDPPacket, style);
}
private void init()
{
receiveThread = new Thread(new ThreadStart(ReceiveData));
receiveThread.IsBackground = true;
receiveThread.Start();
}
private void ReceiveData()
{
client = new UdpClient(port);
while (true)
{
try
{
IPEndPoint anyIP = new IPEndPoint(IPAddress.Any, 0);
byte[] data = client.Receive(ref anyIP);
string text = Encoding.UTF8.GetString(data);
print(">> " + text);
lastReceivedUDPPacket = text;
}
catch (Exception err)
{
print(err.ToString());
}
}
}
}