EIO_Status CListeningSocket::Accept(CSocket&        sock,
                                    const STimeout* timeout,
                                    TSOCK_Flags     flags) const
{
    SOCK       x_sock;
    EIO_Status status;
    if ( !m_Socket ) {
        x_sock = 0;
        status = eIO_Closed;
    } else
        status = LSOCK_AcceptEx(m_Socket, timeout, &x_sock, flags);
    assert(!x_sock ^ !(status != eIO_Success));
    sock.Reset(x_sock, eTakeOwnership, eCopyTimeoutsToSOCK);
    return status;
}
Example #2
0
static SOCK s_GrabSOCK(CSocket& socket)
{
    SOCK sock = socket.GetSOCK();
    if (!sock) {
        NCBI_THROW(CIO_Exception, eInvalidArg,
                   "CConn_SocketStream::CConn_SocketStream(): "
                   " Socket may not be empty");
    }
    if (socket.SetOwnership(eNoOwnership) == eNoOwnership) {
        NCBI_THROW(CIO_Exception, eInvalidArg,
                   "CConn_SocketStream::CConn_SocketStream(): "
                   " Socket must be owned");
    }
    socket.Reset(0/*empty*/,
                 eNoOwnership/*irrelevant*/,
                 eCopyTimeoutsFromSOCK/*irrelevant*/);
    return sock;
}