private void InitUdpServer() { udpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); localEndPoint = new IPEndPoint(IPAddress.Any, GlobleSetting.UdpPort); udpSocket.Bind(localEndPoint); var state = new ServerUdpState(); Udp_WaitForData(state); }
private void Udp_WaitForData(ServerUdpState state) { try { udpSocket.BeginReceiveFrom(state.buffer, 0, ServerUdpState.BufferSize, 0, ref localEndPoint, Udp_ProcessDataRecieved, state); } catch (ObjectDisposedException odex) { //do nothing } catch (Exception ex) { ErrorLogger.LogException(ex); } }