开发者

mono, unix sockets

开发者 https://www.devze.com 2022-12-11 12:02 出处:网络
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. Aft

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

精彩评论

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