This repository was archived by the owner on Dec 23, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed
Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -151,14 +151,22 @@ public void StopListening()
151151 {
152152 if ( ! _listener . Server . IsBound )
153153 return ;
154-
155- _listener . Server . Shutdown ( SocketShutdown . Both ) ;
156- _listener . Server . Close ( 0 ) ;
154+
155+ _listener . Stop ( ) ;
157156 }
158157
159158 private void OnAccept ( IAsyncResult result )
160159 {
161- var tcpClient = _listener . EndAcceptTcpClient ( result ) ;
160+ TcpClient tcpClient ;
161+ try
162+ {
163+ tcpClient = _listener . EndAcceptTcpClient ( result ) ;
164+ }
165+ catch ( ObjectDisposedException )
166+ {
167+ LogDebug ( "Socket was closed" ) ;
168+ return ;
169+ }
162170
163171 var ip = ( ( IPEndPoint ) tcpClient . Client . RemoteEndPoint ) . Address ;
164172
Original file line number Diff line number Diff line change 33using System . IO ;
44using System . Net ;
55using System . Net . Sockets ;
6+ using System . Threading ;
67using RCONServerLib . Utils ;
78
89namespace RCONServerLib
@@ -183,6 +184,11 @@ private void OnPacket(IAsyncResult result)
183184 _remoteConServer . LogDebug ( ( ( IPEndPoint ) _tcp . Client . RemoteEndPoint ) . Address + " lost connection." ) ;
184185 CloseConnection ( ) ;
185186 }
187+ catch ( ThreadAbortException )
188+ {
189+ _remoteConServer . LogDebug ( ( ( IPEndPoint ) _tcp . Client . RemoteEndPoint ) . Address + " socket closed." ) ;
190+ CloseConnection ( ) ;
191+ }
186192 catch ( RconServerException )
187193 {
188194 throw ;
You can’t perform that action at this time.
0 commit comments