Closed
Description
According to https://github.com/dotnet/corefx/issues/10981, I copied the implementation from corefx/src/System.Net.Sockets/tests/FunctionalTests/UnixDomainSocketTest.cs and use it locally like below. (I'm using dotnet core 2.0.0 on Ubuntu)
Socket s = new Socket(AddressFamily.Unix, SocketType.Dgram, ProtocolType.Unspecified);
Console.WriteLine(s.SendBufferSize);
Console.WriteLine(s.ReceiveBufferSize);
var unixSocket = "./my.sock.1";
var ep = new UnixDomainSocketEndPoint(unixSocket);
Console.WriteLine(ep.AddressFamily);
try
{
System.IO.File.Delete(unixSocket);
s.Bind(ep);
s.Listen(5); //// **Operation not supported**
while(true)
{
var newS = s.Accept();
byte[] content = new byte[1000];
var result = s.Receive(content);
Console.WriteLine(result);
Console.WriteLine(Encoding.Default.GetString(content));
newS.Close();
}
}
catch(Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine(e.StackTrace);
s.Close();
}
The exception is something like below:
Operation not supported
at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
at System.Net.Sockets.Socket.Listen(Int32 backlog)
at test01.Program.Main(String[] args) in /home/klein/code/temp/test01/Program.cs:line 106
Is there any solution or workaround to let dotnet core build a domain socket server in Linux? Thanks!