pull/1/head
Ogoun 5 years ago
parent 3ff50a0d76
commit fe6eabb194

@ -12,6 +12,9 @@ namespace ZeroLevel.Network
IRouter UseHost(); IRouter UseHost();
IRouter UseHost(int port); IRouter UseHost(int port);
IRouter UseHostV6();
IRouter UseHostV6(int port);
IRouter UseHost(IPEndPoint endpoint); IRouter UseHost(IPEndPoint endpoint);
IServiceRoutesStorage RoutesStorage { get; } IServiceRoutesStorage RoutesStorage { get; }

@ -633,6 +633,16 @@ namespace ZeroLevel.Network
return MakeHost(new IPEndPoint(IPAddress.Any, port)); return MakeHost(new IPEndPoint(IPAddress.Any, port));
} }
public IRouter UseHostV6()
{
return MakeHost(new IPEndPoint(IPAddress.IPv6Any, NetUtils.GetFreeTcpPort()));
}
public IRouter UseHostV6(int port)
{
return MakeHost(new IPEndPoint(IPAddress.IPv6Any, port));
}
public IRouter UseHost(IPEndPoint endpoint) public IRouter UseHost(IPEndPoint endpoint)
{ {
return MakeHost(endpoint); return MakeHost(endpoint);

@ -61,7 +61,7 @@ namespace ZeroLevel.Network
{ {
try try
{ {
_clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _clientSocket = new Socket(ep.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
_clientSocket.SetIPProtectionLevel(IPProtectionLevel.Unrestricted); _clientSocket.SetIPProtectionLevel(IPProtectionLevel.Unrestricted);
_clientSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, true); _clientSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, true);
_clientSocket.Connect(ep); _clientSocket.Connect(ep);

@ -60,7 +60,7 @@ namespace ZeroLevel.Network
{ {
_router = router; _router = router;
LocalEndpoint = endpoint; LocalEndpoint = endpoint;
_serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _serverSocket = new Socket(endpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
_serverSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true); _serverSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
_serverSocket.Bind(endpoint); _serverSocket.Bind(endpoint);
_serverSocket.Listen(100); _serverSocket.Listen(100);

Loading…
Cancel
Save

Powered by TurnKey Linux.