Initialize a TCP client connection (hzIpConnex instance). This is called from within the select and the epoll server functions and in general, server programs based on HadronZoo would use one of the server functions and so have no need to call this function directly.
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hzIpConnex::Initialize | (hzIpListen*,SSL*,hzIpaddr,uint32_t,uint32_t,uint32_t,) |
Declared in file: hzIpServer.h
Defined in file : hzIpServer.cpp
Function Logic:
Function body:
hzEcode hzIpConnex::Initialize (hzIpListen* pLS)SSL* pSSL, hzIpaddr ipa, uint32_t cliSock, uint32_t cliPort, uint32_t eventNo,
{
// Initialize a TCP client connection (hzIpConnex instance). This is called from within the select and the epoll server functions and in general, server
// programs based on HadronZoo would use one of the server functions and so have no need to call this function directly.
//
// Arguments: 1) Sock The socket file descriptor
// 2) nEvent The event number (usually Nth connection)
// 3) pLS Pointer to the listening socket (hzIpListen instance)
// 4) pSSL The SSL connection (if applicable)
// 5) cpIpa The text representation of the client IP address
//
// Returns: E_ARGUMENT If either the socket or the pointer to the listening socket is not supplied
// E_DUPLICATE If the connection has already got a socket
// E_OK If the TCP connection is initialized
_hzfunc("hzIpConnex::Initialize") ;
if (m_nSock) return hzerr(E_DUPLICATE, "Attempt to init connection to socket %d - already has socket %d", cliSock, m_nSock) ;
if (!pLS) return hzerr(E_ARGUMENT, "No listening socket class instance provided") ;
m_nsAccepted = RealtimeNano() ;
m_ClientIP = ipa ;
m_nSock = cliSock ;
m_nPort = cliPort ;
m_nMsgno = eventNo ;
m_OnIngress = pLS->m_OnIngress ;
m_OnConnect = pLS->m_OnConnect ;
m_appFn = pLS->m_appFn ;
m_pSSL = pSSL ;
m_pLog = pLS->GetLogger() ;
Oxygen() ;
m_bState = CLIENT_INITIALIZED ;
if (pLS->Opflags() & HZ_LISTEN_HTTP)
// m_pEventHdl = (void*) new hzHttpEvent(m_Input, this) ;
m_pEventHdl = new hzHttpEvent(m_Input, this) ;
return E_OK ;
}