Example #1
0
 public void Close()
 {
     if (socket != null)
     {
         socket.Close();
     }
 }
Example #2
0
        public override void Disconnect()
        {
            LoggerManager.Instance.Debug("Logic call Disconnect");

            object obj = statusLock;

            Monitor.Enter(obj);
            try
            {
                connectionStatus = ConnectionStatus.ClosedByLogic;
            }
            finally
            {
                Monitor.Exit(obj);
            }

            if (connection != null)
            {
                connection.Disconnect(null);
                connection = null;
            }

            if (socket != null)
            {
                socket.Close();
            }
        }
Example #3
0
 public void Close(string reason)
 {
     if (mSocket != null)
     {
         mSocket.Close(reason);
     }
 }
Example #4
0
        private static void DoUdp(string[] args)
        {
            if (args.Length == 0)
            {
                return;
            }
            else if (args[0].ToLower() == "open")
            {
                if (isUdpOpen)
                {
                    Console.WriteLine("Udp already opened");
                }
                else
                {
                    isUdpOpen = true;
                }
            }
            else if (args[0].ToLower() == "close")
            {
                if (isUdpOpen)
                {
                    //stop listener threads
                }
                else
                {
                    isUdpOpen = false;
                }
            }
            else if (args[0].ToLower() == "bind")
            {
                //because ipv6 string parsing algorithm is complicated, for now and just in console application using .Net class for it
                System.Net.IPAddress ip = System.Net.IPAddress.Parse(args[1]);

                IPv6Address ipv6Address = new IPv6Address(ip.GetAddressBytes());
                ushort      port        = Convert.ToUInt16(args[2]);

                threadUdpListening = new Thread(() => UDPListenerThread(ipv6Address, port));
                threadUdpListening.Start();
            }
            else if (args[0].ToLower() == "send" && args.Length == 4)
            {
                System.Net.IPAddress ip          = System.Net.IPAddress.Parse(args[1]);
                IPv6Address          ipv6Address = new IPv6Address(ip.GetAddressBytes());

                ushort port = Convert.ToUInt16(args[2]);

                byte[] data = Encoding.UTF8.GetBytes(args[3]);

                UdpSocket udpClient = new UdpSocket();
                udpClient.Connect(ipv6Address, port);
                udpClient.Send(data, data.Length);
                udpClient.Close();
            }
        }
Example #5
0
        public void Close()
        {
            //peerList.Clear ();

            resetTcpAlias();
            //hostUser.UIN = 0;
            groupid = 0;
            hostUser.PeerConnect = null;

            if (server != null)
            {
                server.Close();
            }

            Log.info(this, "P2PClientNetWork Close--------------------------!");

            /*if (listenThread != null)
             *      listenThread.Abort ();*/
        }
Example #6
0
        private static void UDPListenerThread(IPv6Address ipAddress, ushort port)
        {
            UdpSocket receiver = new UdpSocket();

            receiver.Bind(ipAddress, port);
            IPv6EndPoint remoteIp = null;

            isUdpListenerRunning = true;

            while (isUdpListenerRunning)
            {
                if (receiver.Poll(-1, SelectMode.SelectRead))
                {
                    byte[] data    = receiver.Receive(ref remoteIp);
                    string message = Encoding.ASCII.GetString(data);
                    Console.WriteLine("\n");
                    Console.WriteLine("{0} bytes from {1} {2} {3}", message.Length, remoteIp.Address, remoteIp.Port, message);
                    Console.WriteLine(">");
                }
            }

            receiver.Close();
            receiver = null;
        }
Example #7
0
 public void Close()
 {
     m_socket.Close();
 }
 public void KcpStop()
 {
     //enabled = false;
     kcpClient.Close();
 }
Example #9
0
 void OnDestroy()
 {
     socket.Close();
 }