Exemplo n.º 1
0
 public void Dispose()
 {
     if (!IsDisposed)
     {
         while (Clients.Count > 0)
         {
             ((Client)Clients[0]).Dispose();
         }
         try
         {
             if (ListenSocket.Connected)
             {
                 ListenSocket.Shutdown(SocketShutdown.Both);
             }
         }
         catch (SocketException se)
         {
             System.Diagnostics.Debug.WriteLine(se);
         }
         catch { }
         finally
         {
             if (ListenSocket != null)
             {
                 ListenSocket.Close();
             }
             IsDisposed = true;
         }
     }
 }
Exemplo n.º 2
0
        public void Dispose()
        {
            if (IsDisposed)
            {
                return;
            }

            while (Clients.Count > 0)
            {
                Clients[0].Dispose();
            }

            try
            {
                ListenSocket.Shutdown(SocketShutdown.Both);
            }
            catch (Exception ex)
            {
                Log.Write(MethodInfo.GetCurrentMethod(), ex);
            }

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

            _IsDisposed = true;
        }
Exemplo n.º 3
0
 public void Dispose()
 {
     if (!IsDisposed)
     {
         while (Clients.Count > 0)
         {
             ((Client)Clients[0]).Dispose();
         }
         try
         {
             ListenSocket.Shutdown(SocketShutdown.Both);
         }
         catch
         {
         }
         finally
         {
             if (ListenSocket != null)
             {
                 ListenSocket.Close();
             }
             IsDisposed = true;
         }
     }
 }
Exemplo n.º 4
0
	///<summary>Restarts listening on the selected IP address and port.</summary>
	///<remarks>This method is automatically called when the listening port or the listening IP address are changed.</remarks>
	///<exception cref="SocketException">There was an error while creating the listening socket.</exception>
	protected void Restart() {
		//If we weren't listening, do nothing
		if (ListenSocket == null)
			return;
		ListenSocket.Close();
		Start();
	}
Exemplo n.º 5
0
        ///<summary>Disposes of the resources (other than memory) used by the Listener.</summary>
        ///<remarks>Stops listening and disposes <em>all</em> the client objects. Once disposed, this object should not be used anymore.</remarks>
        ///<seealso cref ="System.IDisposable"/>
        public void Dispose()
        {
            if (IsDisposed)
            {
                return;
            }
            DateTime time = DateTime.Now;

            while (Clients.Count > 0)
            {
                ((Client)Clients[0]).Dispose();
                if (time < DateTime.Now - TimeSpan.FromMinutes(1))
                {
                    Clients.Clear();
                    break;
                }
            }
            try {
                ListenSocket.Shutdown(SocketShutdown.Both);
            } catch {}
            try
            {
                if (ListenSocket != null)
                {
                    ListenSocket.Close();
                }
            } catch { }
            m_IsDisposed = true;
        }
Exemplo n.º 6
0
 public void Restart()
 {
     if (ListenSocket != null)
     {
         ListenSocket.Close();
         Start();
     }
 }
Exemplo n.º 7
0
 public void Stop()
 {
     if (ListenSocket == null)
     {
         return;
     }
     ListenSocket.Close();
 }
Exemplo n.º 8
0
 protected void Restart()
 {
     if (ListenSocket == null)
     {
         return;
     }
     ListenSocket.Close();
     Start();
 }
Exemplo n.º 9
0
 ///<summary>Called when there's a connection from the remote FTP server waiting to be accepted.</summary>
 ///<param name="ar">The result of the asynchronous operation.</param>
 private void OnPortAccept(IAsyncResult ar)
 {
     try {
         DestinationSocket = ListenSocket.EndAccept(ar);
         ListenSocket.Close();
         ListenSocket = null;
         StartHandshake();
     } catch {
         Dispose();
     }
 }
Exemplo n.º 10
0
	///<summary>Disposes of the resources (other than memory) used by the Listener.</summary>
	///<remarks>Stops listening and disposes <em>all</em> the client objects. Once disposed, this object should not be used anymore.</remarks>
	///<seealso cref ="System.IDisposable"/>
	public void Dispose() {
		if (IsDisposed)
			return;
		while (Clients.Count > 0) {
			((Client)Clients[0]).Dispose();
		}
		try {
			ListenSocket.Shutdown(SocketShutdown.Both);
		} catch {}
		if (ListenSocket != null)
			ListenSocket.Close();
		m_IsDisposed = true;
	}
Exemplo n.º 11
0
 public void CloseSocket()
 {
     try
     {
         ListenSocket.Shutdown(SocketShutdown.Both);
     }
     catch (Exception E)
     {
         Console.WriteLine("CloseSocket Disconnect error, message: {0}", E.Message);
     }
     ListenSocket.Close();
     ListenSocket = null;
     UserToken.TokenClose();
     OnClosed?.Invoke();
 }
Exemplo n.º 12
0
 ///<summary>Disposes of the resources (other than memory) used by the Listener.</summary>
 ///<remarks>Stops listening and disposes <em>all</em> the client objects. Once disposed, this object should not be used anymore.</remarks>
 ///<seealso cref ="System.IDisposable"/>
 public virtual void Dispose()
 {
     if (IsDisposed)
     {
         return;
     }
     while (Clients.Count > 0)
     {
         Clients[0].Dispose();
     }
     try
     {
         ListenSocket.Shutdown(SocketShutdown.Both);
     }
     catch { }
     if (ListenSocket != null)
     {
         ListenSocket.Close();
     }
     m_IsDisposed = true;
 }