Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 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);
     }
 }