Added the ReuseAddress property to the HttpServer class (Associated with pull request #73)
This commit is contained in:
@@ -83,7 +83,8 @@ namespace WebSocketSharp.Net
|
||||
int port,
|
||||
bool secure,
|
||||
string certificateFolderPath,
|
||||
X509Certificate2 defaultCertificate)
|
||||
X509Certificate2 defaultCertificate,
|
||||
bool reuseAddress)
|
||||
{
|
||||
if (secure) {
|
||||
_secure = secure;
|
||||
@@ -92,13 +93,16 @@ namespace WebSocketSharp.Net
|
||||
throw new ArgumentException ("No server certificate could be found.");
|
||||
}
|
||||
|
||||
_endpoint = new IPEndPoint (address, port);
|
||||
_prefixes = new Dictionary<ListenerPrefix, HttpListener> ();
|
||||
|
||||
_unregistered = new Dictionary<HttpConnection, HttpConnection> ();
|
||||
_unregisteredSync = ((ICollection) _unregistered).SyncRoot;
|
||||
|
||||
_socket = new Socket (address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
|
||||
if (reuseAddress)
|
||||
_socket.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
|
||||
|
||||
_endpoint = new IPEndPoint (address, port);
|
||||
_socket.Bind (_endpoint);
|
||||
_socket.Listen (500);
|
||||
|
||||
|
@@ -107,7 +107,8 @@ namespace WebSocketSharp.Net
|
||||
port,
|
||||
secure,
|
||||
httpListener.CertificateFolderPath,
|
||||
httpListener.DefaultCertificate);
|
||||
httpListener.DefaultCertificate,
|
||||
httpListener.ReuseAddress);
|
||||
|
||||
eps[port] = epl;
|
||||
}
|
||||
|
@@ -70,6 +70,7 @@ namespace WebSocketSharp.Net
|
||||
private bool _listening;
|
||||
private HttpListenerPrefixCollection _prefixes;
|
||||
private string _realm;
|
||||
private bool _reuseAddress;
|
||||
private List<ListenerAsyncResult> _waitQueue;
|
||||
private object _waitQueueSync;
|
||||
|
||||
@@ -109,6 +110,16 @@ namespace WebSocketSharp.Net
|
||||
}
|
||||
}
|
||||
|
||||
internal bool ReuseAddress {
|
||||
get {
|
||||
return _reuseAddress;
|
||||
}
|
||||
|
||||
set {
|
||||
_reuseAddress = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
|
Reference in New Issue
Block a user