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 TypeFunction nameArguments
hzEcodehzIpConnex::Initialize(hzIpListen*,SSL*,hzIpaddr,uint32_t,uint32_t,uint32_t,)

Declared in file: hzIpServer.h
Defined in file : hzIpServer.cpp

Function Logic:

0:START 1:unknown 2:Return hzerr(E_DUPLICATE,Attempt to init connection to socket %d - already has socket %d,cliSock,m_nSock) 3:unknown 4:Return hzerr(E_ARGUMENT,No listening socket class instance provided) 5:m_nsAccepted m_ClientIP m_nSock m_nPort m_nMsgno m_OnIngress m_OnConnect m_appFn m_pSSL m_pLog items m_bState 6:unknown 7:m_pEventHdl 8:Return E_OK

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 ;
}