Logo
~Sockets~
~Examples~
~Contact~


Socket::SocketThread Class Reference
[Internal utility]

Detached socket run thread. More...

Inheritance diagram for Socket::SocketThread:

Inheritance graph
[legend]
Collaboration diagram for Socket::SocketThread:

Collaboration graph
[legend]
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 67 of file Socket.h.


Constructor & Destructor Documentation

Socket::SocketThread::SocketThread ( Socket p  ) 

Definition at line 869 of file Socket.cpp.

00870 :Thread(false)
00871 ,m_socket(p)
00872 {
00873         // Creator will release
00874 }

Socket::SocketThread::~SocketThread (  ) 

Definition at line 877 of file Socket.cpp.

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

00878 {
00879         if (IsRunning())
00880         {
00881                 SetRelease(true);
00882                 SetRunning(false);
00883 #ifdef _WIN32
00884                 Sleep(1000);
00885 #else
00886                 sleep(1);
00887 #endif
00888         }
00889 }

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

Definition at line 77 of file Socket.h.

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


Member Function Documentation

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

Implements Thread.

Definition at line 892 of file Socket.cpp.

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

00893 {
00894         SocketHandler h;
00895         h.SetSlave();
00896         h.Add(m_socket);
00897         m_socket -> SetSlaveHandler(&h);
00898         m_socket -> OnDetached();
00899         while (h.GetCount() && IsRunning())
00900         {
00901                 h.Select(0, 500000);
00902         }
00903         // m_socket now deleted oops
00904         // yeah oops m_socket delete its socket thread, that means this
00905         // so Socket will no longer delete its socket thread, instead we do this:
00906         SetDeleteOnExit();
00907 }

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

Definition at line 76 of file Socket.h.

00076 { return m_socket; }

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

Definition at line 78 of file Socket.h.

00078 { return *this; }


Member Data Documentation

Definition at line 79 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