开发者

mono, unix sockets

Does anyone know an example of c# (mono) application that creates unix domain socket and listens to i开发者_JAVA技巧t async way?


Take a look at the method GracefulShutdown() in ModMonoWebSource.cs. After the point where the socket is created, it does not matter any more whether it was a unix domain socket or an IPv4 socket. Accepting connection asynchronously is done in Mono.WebServer/ folder, but I'll let you find out where and how.


May be it approach for this question.

       var listeningPort = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.IP);
        var endPoint = new UnixDomainSocketEndPoint(path);

        listeningPort.Bind(endPoint);

        listeningPort.Listen(0);

        while (true)
        {

            var socket = await listeningPort.AcceptAsync();

            var result = await socket.ReceiveAsync(transferBuffer, CancellationToken.None);
            //...
        }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜