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; } } }
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; }
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; } } }
///<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(); }
///<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; }
public void Restart() { if (ListenSocket != null) { ListenSocket.Close(); Start(); } }
public void Stop() { if (ListenSocket == null) { return; } ListenSocket.Close(); }
protected void Restart() { if (ListenSocket == null) { return; } ListenSocket.Close(); Start(); }
///<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(); } }
///<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; }
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(); }
///<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; }