示例#1
0
void TcpSocketImpl::accept(TcpServer& server, const TcpSocketOptions& o)
{
    int fd = server.impl().accept(o);

    bool inherit = false;
    System::IODeviceImpl::open(fd, inherit);

    log_debug( "accepted " << server.impl().fd() << " => " << this->fd() );
}
示例#2
0
void TcpSocketImpl::accept(const TcpServer& server, unsigned flags)
{
    socklen_t peeraddr_len = sizeof(_peeraddr);

    _fd = server.impl().accept(flags, reinterpret_cast <struct sockaddr*>(&_peeraddr), peeraddr_len);

    if( _fd < 0 )
        throw SystemError("accept");

#ifdef HAVE_ACCEPT4
    IODeviceImpl::open(_fd, false, false);
#else
    bool inherit = (flags & TcpSocket::INHERIT) != 0;
    IODeviceImpl::open(_fd, true, inherit);
#endif
    //TODO ECONNABORTED EINTR EPERM

    _isConnected = true;
    log_debug( "accepted from " << getPeerAddr());
}