当前位置: 首页>>代码示例>>C++>>正文


C++ SocketPtr::native方法代码示例

本文整理汇总了C++中SocketPtr::native方法的典型用法代码示例。如果您正苦于以下问题:C++ SocketPtr::native方法的具体用法?C++ SocketPtr::native怎么用?C++ SocketPtr::native使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SocketPtr的用法示例。


在下文中一共展示了SocketPtr::native方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: addFD

void Poll::addFD(SocketPtr sock, PollHandler handler)
{
	static struct epoll_event ev;

	{
		std::unique_lock<std::mutex> lock(mutex_);
		handlers_[sock->native()] = std::make_tuple(sock, handler);
	}

	ev.events = /*EPOLLET |*/ EPOLLIN | EPOLLOUT;
	ev.data.fd = sock->native();

	int ret = epoll_ctl(fd_, EPOLL_CTL_ADD, sock->native(), &ev);
	if (ret != 0)
	{
		THROW_SYSTEM_ERROR();
	}
}
开发者ID:ClickSmile,项目名称:httpd,代码行数:18,代码来源:Poll.cpp

示例2: Exception

void
SocketAdapter::handleOperations(SocketPtr s, curl_socket_t theCurlSocket) {
    AC_TRACE << "handleOperations: socket " << theCurlSocket << " is " << s->readyState;
    if (!s->boost_socket.is_open()) {
        return;
    }
    // NOTE: this will be called from one of io_service's threads
    switch (s->readyState) {
        case CURL_POLL_OUT:
            if (s->write_in_progress == false) {
                s->write_in_progress = true;
                AC_TRACE << "queuing write " << s->native();
                s->boost_socket.async_write_some(
                        boost::asio::null_buffers(),
                        s->_parent->_strand.wrap(
                        boost::bind(&SocketAdapter::handleWrite, s,
                            boost::asio::placeholders::error)));
            }
            break;
        case CURL_POLL_IN:
            if (s->read_in_progress == false) {
                s->read_in_progress = true;
                AC_TRACE << "queuing read " << s->native();
                s->boost_socket.async_read_some(
                        boost::asio::null_buffers(),
                        s->_parent->_strand.wrap(
                        boost::bind(&SocketAdapter::handleRead, s,
                            boost::asio::placeholders::error)));

            }
            break;
        case CURL_POLL_REMOVE:
            // we don't need to do anything here. We'll keep the connection open 
            // so it can be reused by later clients
            break;
        default:
            throw asl::Exception("Unknown Socket State "+s->readyState); 
    };
}
开发者ID:modemuser,项目名称:y60,代码行数:39,代码来源:SocketAdapter.cpp


注:本文中的SocketPtr::native方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。