本文整理汇总了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();
}
}
示例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);
};
}