本文整理汇总了C++中TCPSocket::Owner方法的典型用法代码示例。如果您正苦于以下问题:C++ TCPSocket::Owner方法的具体用法?C++ TCPSocket::Owner怎么用?C++ TCPSocket::Owner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCPSocket
的用法示例。
在下文中一共展示了TCPSocket::Owner方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
/*------------------------------------------------------------------------------
* MonitorSockets_tep
*
* The server thread lives here. The main guy who waits on socket activity
* and processes incoming packets.
*----------------------------------------------------------------------------*/
void *MonitorSockets_tep(void *p)
{
//pthread_detach(pthread_self());
CICQDaemon *d = (CICQDaemon *)p;
fd_set f;
int nSocketsAvailable, nCurrentSocket, l;
char buf[1024];
while (true)
{
/*pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
pthread_testcancel();*/
f = gSocketManager.SocketSet();
l = gSocketManager.LargestSocket() + 1;
// Add the new socket pipe descriptor
FD_SET(d->pipe_newsocket[PIPE_READ], &f);
if (d->pipe_newsocket[PIPE_READ] >= l) l = d->pipe_newsocket[PIPE_READ] + 1;
// Add the fifo descriptor
if (d->fifo_fd != -1)
{
FD_SET(d->fifo_fd, &f);
if (d->fifo_fd >= l) l = d->fifo_fd + 1;
}
nSocketsAvailable = select(l, &f, NULL, NULL, NULL);
/*pthread_testcancel();
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);*/
nCurrentSocket = 0;
while (nSocketsAvailable > 0 && nCurrentSocket < l)
{
if (FD_ISSET(nCurrentSocket, &f))
{
// New socket event ----------------------------------------------------
if (nCurrentSocket == d->pipe_newsocket[PIPE_READ])
{
read(d->pipe_newsocket[PIPE_READ], buf, 1);
if (buf[0] == 'S')
{
DEBUG_THREADS("[MonitorSockets_tep] Reloading socket info.\n");
}
else if (buf[0] == 'X')
{
DEBUG_THREADS("[MonitorSockets_tep] Exiting.\n");
pthread_exit(NULL);
}
}
// Fifo event ----------------------------------------------------------
if (nCurrentSocket == d->fifo_fd)
{
DEBUG_THREADS("[MonitorSockets_tep] Data on FIFO.\n");
fgets(buf, 1024, d->fifo_fs);
d->ProcessFifo(buf);
}
else
{
INetSocket *s = gSocketManager.FetchSocket(nCurrentSocket);
if (s != NULL && s->Owner() == gUserManager.OwnerUin() &&
d->m_nTCPSrvSocketDesc == -1)
{
/* This is the server socket and it is about to be destoryed
so ignore this message (it's probably a disconnection anyway) */
gSocketManager.DropSocket(s);
}
// Message from the server -------------------------------------------
else if (nCurrentSocket == d->m_nTCPSrvSocketDesc)
{
DEBUG_THREADS("[MonitorSockets_tep] Data on TCP server socket.\n");
SrvSocket *srvTCP = static_cast<SrvSocket*>(s);
if (srvTCP == NULL)
{
gLog.Warn(tr("%sInvalid server socket in set.\n"), L_WARNxSTR);
close(nCurrentSocket);
}
// DAW FIXME error handling when socket is closed..
else if (srvTCP->Recv())
{
CBuffer packet(srvTCP->RecvBuffer());
srvTCP->ClearRecvBuffer();
gSocketManager.DropSocket(srvTCP);
if (!d->ProcessSrvPacket(packet));// d->icqRelogon();
}
else {
// probably server closed socket, try to relogon after a while
// if ping-thread is running already
int nSD = d->m_nTCPSrvSocketDesc;
//.........这里部分代码省略.........