[Modify] Polish it
This commit is contained in:
parent
067f2cd4f9
commit
34ef69cd2c
@ -94,27 +94,43 @@ namespace WebSocketSharp.Net
|
||||
bool reuseAddress
|
||||
)
|
||||
{
|
||||
if (secure) {
|
||||
var cert =
|
||||
getCertificate (endpoint.Port, certificateFolderPath, sslConfig.ServerCertificate);
|
||||
_endpoint = endpoint;
|
||||
|
||||
if (cert == null)
|
||||
throw new ArgumentException ("No server certificate could be found.");
|
||||
if (secure) {
|
||||
var cert = getCertificate (
|
||||
endpoint.Port,
|
||||
certificateFolderPath,
|
||||
sslConfig.ServerCertificate
|
||||
);
|
||||
|
||||
if (cert == null) {
|
||||
var msg = "No server certificate could be found.";
|
||||
|
||||
throw new ArgumentException (msg);
|
||||
}
|
||||
|
||||
_secure = true;
|
||||
_sslConfig = new ServerSslConfiguration (sslConfig);
|
||||
_sslConfig.ServerCertificate = cert;
|
||||
}
|
||||
|
||||
_endpoint = endpoint;
|
||||
_prefixes = new Dictionary<HttpListenerPrefix, HttpListener> ();
|
||||
_unregistered = new Dictionary<HttpConnection, HttpConnection> ();
|
||||
_unregisteredSync = ((ICollection) _unregistered).SyncRoot;
|
||||
_socket =
|
||||
new Socket (endpoint.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
|
||||
|
||||
if (reuseAddress)
|
||||
_socket.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
|
||||
_socket = new Socket (
|
||||
endpoint.Address.AddressFamily,
|
||||
SocketType.Stream,
|
||||
ProtocolType.Tcp
|
||||
);
|
||||
|
||||
if (reuseAddress) {
|
||||
_socket.SetSocketOption (
|
||||
SocketOptionLevel.Socket,
|
||||
SocketOptionName.ReuseAddress,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
_socket.Bind (endpoint);
|
||||
_socket.Listen (500);
|
||||
|
Loading…
Reference in New Issue
Block a user