//CServer m_ServerReference: // Use this for initialization void Start() { //Found this trick to get the initial IP Address, not sure if it works without connection. //http://stackoverflow.com/questions/6803073/get-local-ip-address using (Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, 0)) { socket.Connect("8.8.8.8", 65530); IPEndPoint endPoint = socket.LocalEndPoint as IPEndPoint; m_szClientIP = endPoint.Address.ToString(); Debug.Log(m_szClientIP + " is this client's IP address"); } Debug.LogWarning(CGlobals.GetNistTime().ToString("MM/dd/yyyy hh:mm:ss.fff tt")); //CGlobals.GetNISTTime(); //Client uses as receive udp client m_udpClient = new UdpClient(10000); m_udpClient.EnableBroadcast = true; m_udpClient.MulticastLoopback = true; //Necessary so it receives its own messages in the multicast. //Debug.Log("The updClients ExclusiveAddressUse value is: " + m_udpClient.ExclusiveAddressUse.ToString());// it must false; m_pServer = null; try { m_fTimeSinceLastResponse = 0.0f; Debug.Log("Beginning to receive: "); m_udpClient.BeginReceive(new AsyncCallback(recv), null); m_dtBeginDateTime = GetGlobalTime(); SendUDPMessage('Y', "Begin_Con", m_dtBeginDateTime.ToString("MM/dd/yyyy hh:mm:ss.fff tt"), IPAddress.Broadcast.ToString(), 10000); } catch (Exception e) { Debug.Log("caught exception : " + e.ToString()); } }