private void ReceiveUDP(int loops) { if (udp_server.Available > 0) { byte[] bytes = udp_server.Receive(ref udp_source); //TODO: If Receive fails again after DC, try {} catch {} and spit it into console if (bytes.Length > 0) { // Get & translate first 4 bytes EN_UDP_PACKET_TYPE packet_type = EN_Protocol.BytesToUDPType(bytes); TranslateUDP(udp_source, packet_type, bytes); } } }
private IEnumerator ReceiveUDP() { while (true) { while (udp_client.Available > 0) { byte[] bytes = udp_client.Receive(ref server); if (bytes.Length > 0) { EN_UDP_PACKET_TYPE type = EN_Protocol.BytesToUDPType(bytes); TranslateUDP(type, bytes); udpBytesIn += (uint)bytes.Length; } } yield return(null); } }