mirror of https://github.com/quasar/Quasar.git
Improved SocketException handling
This commit is contained in:
parent
2a2a4e9956
commit
eca75b3a5f
|
@ -3,6 +3,8 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Windows.Forms;
|
||||
using xServer.Core.Data;
|
||||
using xServer.Core.Networking.Utilities;
|
||||
using xServer.Core.Packets;
|
||||
|
||||
|
@ -251,7 +253,7 @@ namespace xServer.Core.Networking
|
|||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (BufferManager == null)
|
||||
BufferManager = new PooledBufferManager(BUFFER_SIZE, 1) { ClearOnReturn = true };
|
||||
|
||||
|
@ -268,6 +270,21 @@ namespace xServer.Core.Networking
|
|||
AcceptClient(null, _item);
|
||||
}
|
||||
}
|
||||
catch (SocketException ex)
|
||||
{
|
||||
if (ex.ErrorCode == 10048)
|
||||
{
|
||||
MessageBox.Show("The port is already in use.", "Listen Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(
|
||||
string.Format(
|
||||
"An unexpected socket error occurred: {0}\n\nError Code: {1}\n\nPlease report this as fast as possible here:\n{2}/issues",
|
||||
ex.Message, ex.ErrorCode, Settings.RepositoryURL), "Unexpected Listen Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
Disconnect();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Disconnect();
|
||||
|
|
|
@ -62,14 +62,14 @@ namespace xServer.Forms
|
|||
{
|
||||
if (ex.ErrorCode == 10048)
|
||||
{
|
||||
MessageBox.Show("The port is already in use.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show("The port is already in use.", "Listen Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(
|
||||
string.Format(
|
||||
"An unexpected socket error occurred: {0}\n\nError Code: {1}\n\nPlease report this as fast as possible here:\n{2}/issues",
|
||||
ex.Message, ex.ErrorCode, Settings.RepositoryURL), "Unexpected Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
ex.Message, ex.ErrorCode, Settings.RepositoryURL), "Unexpected Listen Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
btnStop_Click(sender, null);
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ namespace xServer.Forms
|
|||
MessageBox.Show(
|
||||
string.Format(
|
||||
"An unexpected error occurred: {0}\n\nPlease report this as fast as possible here:\n{1}/issues",
|
||||
ex.Message, Settings.RepositoryURL), "Unexpected Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
ex.Message, Settings.RepositoryURL), "Unexpected Listen Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
btnStop_Click(sender, null);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue