diff --git a/websocket-sharp/Server/WebSocketServer.cs b/websocket-sharp/Server/WebSocketServer.cs index ff849add..136d98b2 100644 --- a/websocket-sharp/Server/WebSocketServer.cs +++ b/websocket-sharp/Server/WebSocketServer.cs @@ -31,7 +31,8 @@ #region Contributors /* * Contributors: - * Juan Manuel Lallana + * - Juan Manuel Lallana + * - Jonas Hovgaard */ #endregion @@ -66,12 +67,12 @@ namespace WebSocketSharp.Server private int _port; private string _realm; private Thread _receiveRequestThread; + private bool _reuseAddress; private bool _secure; private WebSocketServiceManager _services; private volatile ServerState _state; private object _sync; private Uri _uri; - private bool _reuseAddress; #endregion @@ -418,6 +419,36 @@ namespace WebSocketSharp.Server } } + /// + /// Gets or sets a value indicating whether the server is allowed to be bound to an address + /// that is already in use. + /// + /// + /// If you would like to resolve to wait for socket in TIME_WAIT state, you should set + /// this property to true. + /// + /// + /// true if the server is allowed to be bound to an address that is already in use; + /// otherwise, false. The default value is false. + /// + public bool ReuseAddress { + get { + return _reuseAddress; + } + + set { + if (!canSet ("ReuseAddress")) + return; + + if (value ^ _reuseAddress) { + _listener.Server.SetSocketOption ( + SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, value); + + _reuseAddress = value; + } + } + } + /// /// Gets or sets the delegate called to find the credentials for an identity used to /// authenticate a client. @@ -452,39 +483,6 @@ namespace WebSocketSharp.Server } } - /// - /// Gets or sets a value indicating whether the server is allowed to be bound to an address - /// that is already in use. - /// - /// - /// If you would like to resolve to wait for socket TIME_WAIT, you should set this - /// property to true. - /// - /// - /// true if the server is allowed to be bound to an address that is already in use; - /// otherwise, false. The default value is false. - /// - public bool ReuseAddress - { - get - { - return _reuseAddress; - } - - set - { - if (!canSet("ReuseAddress")) - return; - - if (value ^ _reuseAddress) - { - _listener.Server.SetSocketOption( - SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, value); - - _reuseAddress = value; - } - } - } #endregion #region Private Methods @@ -874,6 +872,7 @@ namespace WebSocketSharp.Server _state = ServerState.Stop; } + #endregion } }