aspnetcore repo has an open issue about unix socket not getting cleaned up on exit: dotnet/aspnetcore#14134.
The socket path of a unix domain socket acts as the address.
When the Socket gets disposed, we should make the address available by deleting the file.
With the current behavior, this program fails:
usingSystem;usingSystem.Net.Sockets;namespaceconsole{classProgram{staticvoidMain(string[]args){varendpoint=newUnixDomainSocketEndPoint("/tmp/mysocket");varsocket=newSocket(AddressFamily.Unix,SocketType.Stream,ProtocolType.Unspecified);socket.Bind(endpoint);socket.Dispose();socket=newSocket(AddressFamily.Unix,SocketType.Stream,ProtocolType.Unspecified);socket.Bind(endpoint);}}}$ dotnet run
Unhandled exception. System.Net.Sockets.SocketException (98): Address already in use
at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName) in /_/src/System.Net.Sockets/src/System/Net/Sockets/Socket.cs:line 5111
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress) in /_/src/System.Net.Sockets/src/System/Net/Sockets/Socket.cs:line 738
at System.Net.Sockets.Socket.Bind(EndPoint localEP) in /_/src/System.Net.Sockets/src/System/Net/Sockets/Socket.cs:line 703
at console.Program.Main(String[] args) in /tmp/console/Program.cs:line 15
Deleting the file is a visible change, so we should consider backwards compatibility.
Users are likely to have File.Delete already in their applications. Those calls will no-op (on ENOENT).
@wfurt@antonfirsov@stephentoub @dotnet/ncl what do you think?
aspnetcore repo has an open issue about unix socket not getting cleaned up on exit: dotnet/aspnetcore#14134.
The socket path of a unix domain socket acts as the address.
When the
Socketgets disposed, we should make the address available by deleting the file.With the current behavior, this program fails:
Deleting the file is a visible change, so we should consider backwards compatibility.
Users are likely to have
File.Deletealready in their applications. Those calls will no-op (onENOENT).@wfurt@antonfirsov@stephentoub @dotnet/ncl what do you think?