Logo
~Sockets~
~Examples~
~Contact~


Socket::SocketThread Class Reference
[Internal utility]

Detached socket run thread. More...

#include <Socket.h>

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 69 of file Socket.h.


Constructor & Destructor Documentation

Socket::SocketThread::SocketThread ( Socket p  ) 

Definition at line 1156 of file Socket.cpp.

01157 :Thread(false)
01158 ,m_socket(p)
01159 {
01160         // Creator will release
01161 }

Socket::SocketThread::~SocketThread (  ) 

Definition at line 1164 of file Socket.cpp.

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

01165 {
01166         if (IsRunning())
01167         {
01168                 SetRelease(true);
01169                 SetRunning(false);
01170 #ifdef _WIN32
01171                 Sleep(1000);
01172 #else
01173                 sleep(1);
01174 #endif
01175         }
01176 }

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

Definition at line 79 of file Socket.h.

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


Member Function Documentation

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

Implements Thread.

Definition at line 1179 of file Socket.cpp.

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

01180 {
01181         SocketHandler h;
01182         h.SetSlave();
01183         h.Add(m_socket);
01184         m_socket -> SetSlaveHandler(&h);
01185         m_socket -> OnDetached();
01186         while (h.GetCount() && IsRunning())
01187         {
01188                 h.Select(0, 500000);
01189         }
01190         // m_socket now deleted oops
01191         // yeah oops m_socket delete its socket thread, that means this
01192         // so Socket will no longer delete its socket thread, instead we do this:
01193         SetDeleteOnExit();
01194 }

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

Definition at line 78 of file Socket.h.

00078 { return m_socket; }

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

Definition at line 80 of file Socket.h.

00080 { return *this; }


Member Data Documentation

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