mirror of https://github.com/quasar/Quasar.git
Make sure to dispose of old Socket
Made sure the server disposed of the Socket when Server.Listen(ushort) is called if the Socket was created before (called Server.Listen(ushort) previously but stopped listening).
This commit is contained in:
parent
539a9b3d5b
commit
b927aae0f8
|
@ -94,6 +94,16 @@ public void Listen(ushort port)
|
||||||
_item = new SocketAsyncEventArgs();
|
_item = new SocketAsyncEventArgs();
|
||||||
_item.Completed += Process;
|
_item.Completed += Process;
|
||||||
|
|
||||||
|
if (_handle != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_handle.Close();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
|
||||||
_handle = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
_handle = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||||
|
|
||||||
_handle.Bind(new IPEndPoint(IPAddress.Any, port));
|
_handle.Bind(new IPEndPoint(IPAddress.Any, port));
|
||||||
|
|
Loading…
Reference in New Issue