Ejemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 void ResetInternalLan()
 {
     try
     {
         LogHelper.Trace();
         if (_Comm != null)
         {
             _Comm.Dispose();
             _Comm = null;
             Run();
         }
     }
     catch (Exception x)
     {
         LogHelper.Log(LogLevel.Error, x.Message);
     }
 }
Ejemplo n.º 2
0
 void ResetInternalLan()
 {
     try
     {
         Logger.Trace <Cluster>("ResetInternalLan");
         if (_Comm != null)
         {
             _Comm.Dispose();
             _Comm            = null;
             _ToStart.Enabled = true;
         }
     }
     catch (Exception x)
     {
         Logger.Exception <Cluster>(x);
     }
 }
Ejemplo n.º 3
0
        public void Stop()
        {
            _Stop = true;

            if (_Comm != null)
            {
                _Comm.Dispose();
                _Comm = null;
            }
        }
Ejemplo n.º 4
0
        public void CanDisposeNewUdpSocket()
        {
            using (CompletionThread worker = new CompletionThread())
            {
                SocketFactory factory = new SocketFactory(worker);
                UdpSocket     socket  = factory.Udp();

                socket.Dispose();
            }
        }
Ejemplo n.º 5
0
 protected virtual void Dispose(bool disposing)
 {
     if (!DisposedValue)
     {
         if (disposing)
         {
             // TODO: dispose managed state (managed objects)
         }
         // TODO: free unmanaged resources (unmanaged objects) and override finalizer
         // TODO: set large fields to null
         UdpSocket.Dispose();
         Tun.Dispose();
         DisposedValue = true;
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Disposes the connection.
        /// </summary>
        protected virtual void Dispose(bool disposing)
        {
            if (!isDisposed && disposing)
            {
                isDisposed = true;

                udpSocket.Dispose();
                udpSocket.PacketDataReceived -= udpSocket_PacketDataReceived;
                udpSocket.SocketError        -= udpSocket_SocketError;

                if (timeoutTimer != null)
                {
                    timeoutTimer.Dispose();
                    timeoutTimer.Elapsed -= timeoutTimer_Elapsed;
                }
            }
        }
Ejemplo n.º 7
0
        public void SendReceiveTest()
        {
            const string serverMessage = "HelloFromServer";
            const string clientMessage = "ResponseFromClient";

            IPEndPoint ep       = new IPEndPoint(IPAddress.Any, 666);
            IPEndPoint serverEp = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 666);
            UdpSocket  client   = new UdpSocket();
            UdpSocket  server   = new UdpSocket();

            server.Bind(666);
            Assert.AreEqual(SocketStatus.Done, client.Connect(serverEp));

            NetPacket packet       = new NetPacket();
            NetPacket clientPacket = new NetPacket();

            packet.WriteString(serverMessage);

            // Send message to client.
            Assert.AreEqual(SocketStatus.Done, server.Send(packet, client.LocalEndpoint));

            // Read message from server.
            Assert.AreEqual(SocketStatus.Done, client.Receive(clientPacket, ref ep));
            Assert.AreEqual(serverMessage, clientPacket.ReadString());

            // Send message back to server.
            clientPacket.Clear(SerializationMode.Writing);
            clientPacket.WriteString(clientMessage);
            Assert.AreEqual(SocketStatus.Done, client.Send(clientPacket));

            // Read message from client.
            Assert.AreEqual(SocketStatus.Done, server.Receive(packet, ref ep));
            Assert.AreEqual(clientMessage, packet.ReadString());

            client.Dispose();
            server.Dispose();
            packet.Dispose();
            clientPacket.Dispose();
        }
Ejemplo n.º 8
0
 public void Stop()
 {
     collection.Clear();
     socket?.Dispose();
     socket = null;
 }