Merge pull request #73 from jhovgaard/master
Added ReuseAddress property to WebSocketServer
This commit is contained in:
		| @@ -71,6 +71,7 @@ namespace WebSocketSharp.Server | ||||
|     private volatile ServerState               _state; | ||||
|     private object                             _sync; | ||||
|     private Uri                                _uri; | ||||
|     private bool                               _reuseAddress; | ||||
|  | ||||
|     #endregion | ||||
|  | ||||
| @@ -451,6 +452,39 @@ namespace WebSocketSharp.Server | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     /// <summary> | ||||
|     /// Gets or sets a value indicating whether the server is allowed to be bound to an address | ||||
|     /// that is already in use. | ||||
|     /// </summary> | ||||
|     /// <remarks> | ||||
|     /// If you would like to resolve to wait for socket <c>TIME_WAIT</c>, you should set this | ||||
|     /// property to <c>true</c>. | ||||
|     /// </remarks> | ||||
|     /// <value> | ||||
|     /// <c>true</c> if the server is allowed to be bound to an address that is already in use; | ||||
|     /// otherwise, <c>false</c>. The default value is <c>false</c>. | ||||
|     /// </value> | ||||
|     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 | ||||
| @@ -840,7 +874,6 @@ namespace WebSocketSharp.Server | ||||
|  | ||||
|       _state = ServerState.Stop; | ||||
|     } | ||||
|  | ||||
|     #endregion | ||||
|   } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user