Logo
~Sockets~
~Examples~
~Contact~


ExtSocket Class Reference

#include <ExtSocket.h>

Collaboration diagram for ExtSocket:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ExtSocket (ISocketHandler &)
 ~ExtSocket ()
void OnAccept ()
void OnDelete ()
void OnRawData (const char *, size_t)
unsigned short GetID ()

Private Member Functions

 ExtSocket (const ExtSocket &s)
ExtSocketoperator= (const ExtSocket &)

Private Attributes

MasterSocketm_parent
unsigned short m_id

Detailed Description

Definition at line 10 of file ExtSocket.h.


Constructor & Destructor Documentation

ExtSocket::ExtSocket ( ISocketHandler &   ) 

Definition at line 9 of file ExtSocket.cpp.

00010 :TcpSocket(h)
00011 ,m_parent(static_cast<MHandler&>(Handler()).GetMasterSocket())
00012 ,m_id(static_cast<MHandler&>(h).GetUniqueID())
00013 {
00014 }

ExtSocket::~ExtSocket (  ) 

Definition at line 17 of file ExtSocket.cpp.

00018 {
00019 }

ExtSocket::ExtSocket ( const ExtSocket s  )  [inline, private]

Definition at line 23 of file ExtSocket.h.

00023 : TcpSocket(s) {} // copy constructor


Member Function Documentation

void ExtSocket::OnAccept (  ) 

Definition at line 22 of file ExtSocket.cpp.

References M2S_OPEN, m_id, and m_parent.

00023 {
00024         MHandler::service_v& ref = static_cast<MHandler&>(Handler()).GetServices();
00025         for (MHandler::service_v::iterator it = ref.begin(); it != ref.end(); it++)
00026         {
00027                 MHandler::SERVICE *p = *it;
00028                 if (p -> port == GetParent() -> GetPort())
00029                 {
00030                         if (Handler().Valid(m_parent))
00031                         {
00032                                 std::string tmp = p -> remote_host + ":" + Utility::l2string(p -> remote_port);
00033                                 m_parent -> SendCmd(m_id, M2S_OPEN, tmp.size());
00034                                 m_parent -> Send(tmp);
00035                         }
00036                 }
00037         }
00038 }

void ExtSocket::OnDelete (  ) 

Definition at line 41 of file ExtSocket.cpp.

References M2S_CLOSE, m_id, and m_parent.

00042 {
00043         if (Handler().Valid(m_parent))
00044         {
00045                 m_parent -> SendCmd(m_id, M2S_CLOSE);
00046         }
00047 }

void ExtSocket::OnRawData ( const char *  ,
size_t   
)

Definition at line 50 of file ExtSocket.cpp.

References M2S_DATA, m_id, and m_parent.

00051 {
00052         if (Handler().Valid(m_parent))
00053         {
00054                 m_parent -> SendCmd(m_id, M2S_DATA, len);
00055                 m_parent -> SendBuf(buf, len);
00056         }
00057         ibuf.Remove(ibuf.GetLength());
00058 }

unsigned short ExtSocket::GetID (  )  [inline]

Definition at line 20 of file ExtSocket.h.

References m_id.

00020 { return m_id; }

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

Definition at line 24 of file ExtSocket.h.

00024 { return *this; } // assignment operator


Member Data Documentation

Definition at line 25 of file ExtSocket.h.

Referenced by OnAccept(), OnDelete(), and OnRawData().

unsigned short ExtSocket::m_id [private]

Definition at line 26 of file ExtSocket.h.

Referenced by GetID(), OnAccept(), OnDelete(), and OnRawData().


The documentation for this class was generated from the following files:
Page, code, and content Copyright (C) 2006 by Anders Hedström
Generated on Mon Aug 29 20:21:47 2005 for C++ Sockets by  doxygen 1.4.4