/// <summary> /// Disconnects the client /// </summary> private void Disconnect() { try { if (ClientSocket.Connected) { ClientSocket.Shutdown(SocketShutdown.Both); } if (ClientSocket != null && ClientSocket.Connected) { ClientSocket.Close(); } ClientSocket = null; if (_DataListener != null) { _DataListener.Stop(); } _DataListener = null; ClientEndPoint = null; _FTPUser = null; FTP.FtpServer.FTPClientsList.Remove(this); FTP.NewServerLog("Client disconnected"); GC.Collect(); } catch (SocketException ex) { FTP.NewServerLog("Disconnect " + ex.Message); } catch (ObjectDisposedException ex) { FTP.NewServerLog("Disconnect " + ex.Message); } }
/// <summary> /// Constructor /// </summary> /// <param name="clientsocket"></param> public FTPClient(Socket clientsocket) { try { this.ClientSocket = clientsocket; ConnectedAt = DateTime.Now; ClientSocket.NoDelay = false; _FTPUser = new FTPUser(); SendMessage("220 FTP Ready\r\n"); ClientSocket.BeginReceive(_Data, 0, _Data.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), ClientSocket); } catch (SocketException ex) { FTP.NewServerLog("BeginReceive " + ex.Message); } catch (ObjectDisposedException ex) { FTP.NewServerLog("BeginReceive " + ex.Message); } }