Logo
~Sockets~
~Examples~
~Contact~


Socket::SocketThread Class Reference
[Internal utility]

Detached socket run thread. More...

Inheritance diagram for Socket::SocketThread:
Collaboration diagram for Socket::SocketThread:

List of all members.


Public Member Functions

 SocketThread (Socket *p)
 ~SocketThread ()
void Run ()

Private Member Functions

SocketGetSocket () const
 SocketThread (const SocketThread &s)
SocketThreadoperator= (const SocketThread &)

Private Attributes

Socketm_socket

Detailed Description

Detached socket run thread.

Definition at line 66 of file Socket.h.


Constructor & Destructor Documentation

Socket::SocketThread::SocketThread ( Socket p  ) 

Definition at line 886 of file Socket.cpp.

00887 :Thread(false)
00888 ,m_socket(p)
00889 {
00890         // Creator will release
00891 }

Socket::SocketThread::~SocketThread (  ) 

Definition at line 894 of file Socket.cpp.

References Thread::IsRunning(), Thread::SetRelease(), and Thread::SetRunning().

00895 {
00896         if (IsRunning())
00897         {
00898                 SetRelease(true);
00899                 SetRunning(false);
00900 #ifdef _WIN32
00901                 Sleep(1000);
00902 #else
00903                 sleep(1);
00904 #endif
00905         }
00906 }

Socket::SocketThread::SocketThread ( const SocketThread s  )  [inline, private]

Definition at line 76 of file Socket.h.

00076 : m_socket(s.GetSocket()) {}


Member Function Documentation

void Socket::SocketThread::Run (  )  [virtual]

Implements Thread.

Definition at line 909 of file Socket.cpp.

References SocketHandler::Add(), SocketHandler::GetCount(), Thread::IsRunning(), m_socket, Socket::OnDetached(), SocketHandler::Select(), Thread::SetDeleteOnExit(), SocketHandler::SetSlave(), and Socket::SetSlaveHandler().

00910 {
00911         SocketHandler h;
00912         h.SetSlave();
00913         h.Add(m_socket);
00914         m_socket -> SetSlaveHandler(&h);
00915         m_socket -> OnDetached();
00916         while (h.GetCount() && IsRunning())
00917         {
00918                 h.Select(0, 500000);
00919         }
00920         // m_socket now deleted oops
00921         // yeah oops m_socket delete its socket thread, that means this
00922         // so Socket will no longer delete its socket thread, instead we do this:
00923         SetDeleteOnExit();
00924 }

Socket* Socket::SocketThread::GetSocket (  )  const [inline, private]

Definition at line 75 of file Socket.h.

00075 { return m_socket; }

SocketThread& Socket::SocketThread::operator= ( const SocketThread  )  [inline, private]

Definition at line 77 of file Socket.h.

00077 { return *this; }


Member Data Documentation

Definition at line 78 of file Socket.h.

Referenced by Run().


The documentation for this class was generated from the following files:
Page, code, and content Copyright (C) 2007 by Anders Hedström
Generated for C++ Sockets by  doxygen 1.4.4