Added SetReuseAddress() method to WebSocketServer - #73
Merged
Conversation
Owner
|
It looks interesting. But, isn't it better to add as a property? ...
private bool _reuseAddress;
...
/// <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;
}
}
}
...Could you test the above? |
Contributor
Author
|
I agree, better with property. It worked perfectly. Commited. |
Owner
|
I will merge this PR, and then add the following comment to that .cs file. /*
* Contributors:
* - Jonas Hovgaard <j@jhovgaard.dk>
*/Is it okay? |
Contributor
Author
|
Yes, that's cool :-) |
sta
added a commit
that referenced
this pull request
Aug 28, 2014
Added ReuseAddress property to WebSocketServer
sta
added a commit
that referenced
this pull request
Aug 28, 2014
sta
added a commit
that referenced
this pull request
Sep 4, 2014
…lso closes the underlying Socket, and creates a new Socket for the TcpListener. If you set any properties on the underlying Socket prior to calling the Stop method, those properties will not carry over to the new Socket.'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
By using
SetReuseAddress()beforeStart()you don't have to wait for TIME_WAIT to timeout. Normally you will recieve the following exception if you try to start websocket-sharp on the same port within TIME_WAIT: