本文整理汇总了C++中CSocket::GetSOCK方法的典型用法代码示例。如果您正苦于以下问题:C++ CSocket::GetSOCK方法的具体用法?C++ CSocket::GetSOCK怎么用?C++ CSocket::GetSOCK使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSocket
的用法示例。
在下文中一共展示了CSocket::GetSOCK方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: s_GrabSOCK
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;
}
示例2: Poll
EIO_Status CSocketAPI::Poll(vector<SPoll>& polls,
const STimeout* timeout,
size_t* n_ready)
{
static const STimeout kZero = {0, 0};
size_t x_n = polls.size();
SPOLLABLE_Poll* x_polls = 0;
size_t x_ready = 0;
if (x_n && !(x_polls = new SPOLLABLE_Poll[x_n]))
return eIO_Unknown;
for (size_t i = 0; i < x_n; i++) {
CPollable* p = polls[i].m_Pollable;
EIO_Event event = polls[i].m_Event;
if (p && event) {
CSocket* s = dynamic_cast<CSocket*> (p);
if (!s) {
CListeningSocket* ls = dynamic_cast<CListeningSocket*> (p);
if (!ls) {
CTrigger* tr = dynamic_cast<CTrigger*> (p);
x_polls[i].poll = POLLABLE_FromTRIGGER(tr
? tr->GetTRIGGER()
: 0);
} else
x_polls[i].poll = POLLABLE_FromLSOCK(ls->GetLSOCK());
polls[i].m_REvent = eIO_Open;
} else {
EIO_Event revent;
if (s->GetStatus(eIO_Open) != eIO_Closed) {
x_polls[i].poll = POLLABLE_FromSOCK(s->GetSOCK());
revent = eIO_Open;
} else {
x_polls[i].poll = 0;
revent = eIO_Close;
x_ready++;
}
polls[i].m_REvent = revent;
}
x_polls[i].event = event;
} else {
x_polls[i].poll = 0;
polls[i].m_REvent = eIO_Open;
}
}
size_t xx_ready;
EIO_Status status = POLLABLE_Poll(x_n, x_polls,
x_ready ? &kZero : timeout, &xx_ready);
for (size_t i = 0; i < x_n; i++) {
if (x_polls[i].revent)
polls[i].m_REvent = x_polls[i].revent;
}
if (n_ready)
*n_ready = xx_ready + x_ready;
delete[] x_polls;
return status;
}