using System; using System.Collections; using System.Collections.Generic; using System.Net; using System.Net.Sockets; using System.Text; using System.Threading; using UnityEngine; public class UDPPrinter : MonoBehaviour { private UDPUtility udpUtil; // Start is called before the first frame update void Start() { udpUtil = new UDPUtility("192.168.1.41", 20000); udpUtil.sendData("hello everyone!"); } // Update is called once per frame void Update() { if (udpUtil != null && !"".Equals(udpUtil.getReceivedValue())) { Debug.Log(udpUtil.receivedData.Value); } } private void OnDestroy() { if (udpUtil.reciveT != null && udpUtil.reciveT.ThreadState == ThreadState.Running) { udpUtil.reciveT.Abort(); } } }