Skip to content

Commit

Permalink
Simplify unix sockets logic
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfowl committed May 29, 2019
1 parent 3f72825 commit 90ca693
Showing 1 changed file with 4 additions and 8 deletions.
Expand Up @@ -64,14 +64,10 @@ internal void Bind()

Socket listenSocket;

if (EndPoint is UnixDomainSocketEndPoint)
{
listenSocket = new Socket(EndPoint.AddressFamily, SocketType.Stream, ProtocolType.Unspecified);
}
else
{
listenSocket = new Socket(EndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
}
// Unix domain sockets are unspecified
var protocolType = EndPoint is UnixDomainSocketEndPoint ? ProtocolType.Unspecified : ProtocolType.Tcp;

listenSocket = new Socket(EndPoint.AddressFamily, SocketType.Stream, protocolType);

// Kestrel expects IPv6Any to bind to both IPv6 and IPv4
if (EndPoint is IPEndPoint ip && ip.Address == IPAddress.IPv6Any)
Expand Down

0 comments on commit 90ca693

Please sign in to comment.