Example #1
0
        public bool TryAccept(Ring ring, out LinuxSocket socket)
        {
            if (IsIpSocket)
            {
                _addr.AsSpan().Clear();
                *AddrLen = SizeOf.sockaddr_storage;
            }

            if (!ring.Supports(RingOperation.Accept))
            {
                // pre v5.5
                socket = Socket.Accept4(Addr, AddrLen, SOCK_NONBLOCK | SOCK_CLOEXEC);
                return(true);
            }

            socket = default;
            int acceptSocket = Socket;

            if (!ring.TryPrepareAccept(acceptSocket, Addr, AddrLen, SOCK_NONBLOCK | SOCK_CLOEXEC, AsyncOperation.AcceptFrom(acceptSocket).AsUlong()))
            {
                _scheduler.ScheduleAccept(acceptSocket);
            }

            return(false);
        }