00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "stdafx.h"
00037 #include "TCPSocketAsyncDelegator.h"
00038
00039 #include "ErrorHandlerMacros.h"
00040
00041 #include "TCPSocketAsync.h"
00042
00043 #ifdef _MEMORY_DEBUG
00044 #define new DEBUG_NEW
00045 #define malloc DEBUG_MALLOC
00046 static char THIS_FILE[] = __FILE__;
00047 #endif
00048
00049 KOMODIA_NAMESPACE_START
00050
00051 #define CTCPSocketAsyncDelegator_Class "CTCPSocketAsyncDelegator"
00052
00053 CTCPSocketAsyncDelegator::CTCPSocketAsyncDelegator(CTCPSocketAsync* pSocket) : CErrorHandler(),
00054 m_pSocket(pSocket)
00055 {
00056 try
00057 {
00058
00059 SetName(CTCPSocketAsyncDelegator_Class);
00060 }
00061 ERROR_HANDLER("CTCPSocketAsyncDelegator")
00062 }
00063
00064 CTCPSocketAsyncDelegator::~CTCPSocketAsyncDelegator()
00065 {
00066 }
00067
00068 CTCPSocketAsync* CTCPSocketAsyncDelegator::GetSocket()const
00069 {
00070 return m_pSocket;
00071 }
00072
00073 BOOL CTCPSocketAsyncDelegator::SocketConnected(int iErrorCode,
00074 BOOL bNoEvent)
00075 {
00076 return m_pSocket->SocketConnected(iErrorCode,
00077 bNoEvent);
00078 }
00079
00080 BOOL CTCPSocketAsyncDelegator::LocalSocketConnect(int iErrorCode,
00081 BOOL bNoEvent)
00082 {
00083 return m_pSocket->LocalSocketConnect(iErrorCode,
00084 bNoEvent);
00085 }
00086
00087 BOOL CTCPSocketAsyncDelegator::OnSocketConnect(int iErrorCode)
00088 {
00089 return m_pSocket->OnSocketConnect(iErrorCode);
00090 }
00091
00092 BOOL CTCPSocketAsyncDelegator::LocalSocketReceive(int iErrorCode,
00093 BOOL bNoEvent)
00094 {
00095 return m_pSocket->LocalSocketReceive(iErrorCode,
00096 bNoEvent);
00097 }
00098
00099 BOOL CTCPSocketAsyncDelegator::LocalConnect(unsigned short usSourcePort,
00100 IP aDestinationAddress,
00101 unsigned short usDestinationPort,
00102 BOOL bDisableAsync,
00103 BOOL bForceErrorEvent)
00104 {
00105 return m_pSocket->LocalConnect(usSourcePort,
00106 aDestinationAddress,
00107 usDestinationPort,
00108 bDisableAsync,
00109 bForceErrorEvent);
00110 }
00111
00112 BOOL CTCPSocketAsyncDelegator::LocalBind(IP aSourceAddress,
00113 unsigned short usPort)
00114 {
00115 return m_pSocket->LocalBind(aSourceAddress,
00116 usPort);
00117 }
00118
00119 BOOL CTCPSocketAsyncDelegator::LocalSocketClose(int iErrorCode,
00120 BOOL bNoEvent)
00121 {
00122 return m_pSocket->LocalSocketClose(iErrorCode,
00123 bNoEvent);
00124 }
00125
00126 void CTCPSocketAsyncDelegator::SetConnectedTo(const sockaddr_in& rAddress)
00127 {
00128
00129 m_pSocket->SetConnectedTo(rAddress);
00130 }
00131
00132 void CTCPSocketAsyncDelegator::SwitchEventsType()
00133 {
00134
00135 m_pSocket->SwitchEventsType();
00136 }
00137
00138 BOOL CTCPSocketAsyncDelegator::SetAsync()
00139 {
00140
00141 m_pSocket->ClearEvents();
00142
00143
00144 return m_pSocket->SetAsync();
00145 }
00146
00147 IP CTCPSocketAsyncDelegator::LocalGetBindAddress()const
00148 {
00149 return m_pSocket->LocalGetBindAddress();
00150 }
00151
00152 unsigned short CTCPSocketAsyncDelegator::LocalGetBindPort()const
00153 {
00154 return m_pSocket->LocalGetBindPort();
00155 }
00156
00157 BOOL CTCPSocketAsyncDelegator::LocalSocketAccept(int iErrorCode,
00158 BOOL bNoEvent)
00159 {
00160 return m_pSocket->LocalSocketAccept(iErrorCode,
00161 bNoEvent);
00162 }
00163
00164 BOOL CTCPSocketAsyncDelegator::LocalAccept(CTCPSocket* pNewSocket)
00165 {
00166 return m_pSocket->LocalAccept(pNewSocket);
00167 }
00168
00169 void CTCPSocketAsyncDelegator::SetAcceptance(CTCPSocket* pNewSocket,
00170 SOCKET aSocket,
00171 sockaddr_in aAddress)const
00172 {
00173 m_pSocket->SetAcceptance(pNewSocket,
00174 aSocket,
00175 aAddress);
00176 }
00177
00178 BOOL CTCPSocketAsyncDelegator::ClearEvents()
00179 {
00180 return m_pSocket->ClearEvents();
00181 }
00182
00183 SOCKET CTCPSocketAsyncDelegator::Detach()
00184 {
00185 return m_pSocket->Detach();
00186 }
00187
00188 BOOL CTCPSocketAsyncDelegator::LocalListen(unsigned long ulBackLog)
00189 {
00190 return m_pSocket->LocalListen(ulBackLog);
00191 }
00192
00193 KOMODIA_NAMESPACE_END