public UdpServerSocket_Base(int Port, System.Action OnPacketReady, System.Action <int> OnListening, System.Action <string> OnCloseError, System.Action <float> OnKbpsReport) { if (OnKbpsReport == null) { OnKbpsReport = (Kbps) => Debug.Log("UDP Server Recieved " + Kbps + "kb/s"); } // todo: put some "unhandled" debug in these if (OnPacketReady == null) { OnPacketReady = () => { } } ; if (OnCloseError == null) { OnCloseError = (Error) => { } } ; if (OnListening == null) { OnListening = (Portx) => { } } ; RecvKbCounter = new FrameCounter(OnKbpsReport, 1.0f); this.OnPacketReady = OnPacketReady; this.OnCloseError = OnCloseError; ListeningEndPoint = new IPEndPoint(IPAddress.Any, Port); Socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); Socket.Bind(ListeningEndPoint); var ReceiveBufferSize = Socket.ReceiveBufferSize; Debug.Log("Socket ReceiveBufferSize=" + ReceiveBufferSize); var LocalEndPoint = (IPEndPoint)Socket.LocalEndPoint; OnListening.Invoke(LocalEndPoint.Port); StartRecv(); }