Defined in file: hzIpServer.h

Generic client connection

Constructors/Detructors

hzIpConnex*hzIpConnex(hzLogger* pLog)
NULL-TYPEhzIpConnex(hzLogger* pLog)
void~hzIpConnex(void)
NULL-TYPE~hzIpConnex(void)if (_hzGlobal_Debug & HZ_DEBUG_SERVER) threadLog("NOTE: Connection under Destruction still has a socket %d\n", m_nSock) ;

Public Methods:

uint32_tCliPort(void)
uint32_tCliSocket(void)
hzIpaddrClientIP(void)
uint32_tEventNo(void)
voidExpectSize(uint32_t nBytes)
uint32_tExpectSize(void)
uint64_tExpires(void)
hzIpConnInfo*GetInfo(void)
hzLogger*GetLogger(void)
voidHypoxia(void)
hzEcodeInitialize(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.
hzChain&InputZone(void)
boolIsCliBad(void)
boolIsCliTerm(void)
boolIsVirgin(void)
boolMsgComplete(void)
boolMsgReady(void)If a message has an expected size this condition will only be true if the input so far has reached or exceeded this size. In the common scenario where an incoming message has a header stating the length, the expected size starts at zero and this function returns true. The input is then provisionally processed and this will establish the expected size. This function will then not return true until the whole message in in.
voidOxygen(void)
int32_tRecv(hzPacket& tbuf)Receive a packet of data from the client socket and append it to the input chain. Scope: This function should not be called by the application!
hzEcodeSendData(hzChain& Hdr)hzChain& Body, Send a response to the client as a separate header and message body. This approach means a cost of two partial IP packets instead of one, but it saves having to concatenate the two chains which is a heavy copying operation. Note that this function should always be called by applications rather than writing to the client socket directly as this ensures proper multiplexing between clients.
hzEcodeSendData(hzChain& Z)Send a response to the client. This function should always be called by applications rather than writing to the client socket directly as this ensures proper multiplexing between clients.
voidSendKill(void)Sent by connection handler in response to illegal message. The status is set to CLIENT_BAD but the socket is still made ready for epoll write events. As soon as the socket is available for writes however, the connection is terminated and deleted. The client recieves no response to their request. Arguments: None Returns: None
voidSetInfo(hzIpConnInfo* pInfo)
voidSetSocket(uint32_t nSock)
uint32_tSizeIn(void)
voidTerminate(void)This is called within ServeEpollST or ServeEpollMT in the event of an epoll error being detected. The origin of the epoll error would be such as connection reset by peer, or a broken pipe. The remedial action is to remove any remaining outgoing data as this has no chance of being delivered to the client. However the socket itself is not closed immeadiately. This is left open for a limited period so that it is not assigned to another connection. Arguments: None Returns: None
uint64_tTimeAcpt(void)
uint64_tTimeProc(void)
uint64_tTimeRecv(void)
uint64_tTimeXmit(void)
uint32_tTotalIn(void)
uint32_tTotalOut(void)
bool_isxmit(void)
int32_t_xmit(hzPacket& tbuf)In the epoll loop, this function is called for each client connection with a write event on the socket (the socket becomes available for writing). If no output is pending, this function does nothing and returns. This approach serves to multiplex output so that no socket is left hanging during large downloads. The term 'output' depends on the perspective. There are three possible scenarios as follows:- - The connection is that of a direct client of this service, with no proxy. In this case the connection m_Input member is populated by read events the output will be the response to an earlier request. - The connection is that of a client of this service, but has a proxy connection to another service. In this case the output will be the request from the client, to be passed to the other service. - The connection is the proxy connection to another service. In this case the input from epoll read events, is actually the response from the other service - which must be passed to the client. Note that in the epoll loop, read events always add data to the m_Input member of the applicable connection In the direct case, this function will write data to the client socket until either the socket write buffer is full, or the outgoing message is exhausted. In the has

Member Variables:

sockaddr_inm_CliAddrIP Addres of client socket
hzIpaddrm_ClientIPIP address of client
uint64_tm_ConnExpiresNanosecond Epoch expiry
hzChainm_InputIncomming message chain
hzChain::Iterm_MsgStartFor iteration of pipelined requests
hzTcpCode(*)(hzIpConnex*)m_OnConnectOptional: Called on connection e.g. Server hello.
hzTcpCode(*)(hzIpConnex*)m_OnDisconnOptional: Called on disconnection for any tidying up.
hzTcpCode(*)(hzChain&,hzIpConnex*)m_OnIngressRequired: Function to handle messages comming in on the specific port.
hzPktQuem_OutgoingOutgoing message stream
void*m_appFnApplication message event handler
boolm_bAcceptSSLSSL has been accepted
boolm_bInitSSLIf there is an SSL conection, has it been accepted and set up?
uint16_tm_bListenOperational flags from listening socket (HZ_LISTEN_SECURE | HZ_LISTEN_INTERNET | HZ_LISTEN_UDP)
uint32_tm_bStateClient state
intm_nCliLenLength of socket address
uint32_tm_nExpectedExpected size of incomming request
uint32_tm_nGlitchExtent of incomplete write
uint32_tm_nMsgnoEvent/Message number
uint16_tm_nPortIncomimg port
uint32_tm_nSockClient socket
uint32_tm_nStartStart position of current incomming message within chain
uint32_tm_nTotalInTotal size of outgoing response
uint32_tm_nTotalOutTotal size of outgoing response
uint64_tm_nsAcceptedNanosecond Epoch connection accepted
uint64_tm_nsRecvBegNanosecond Epoch first packet of message
uint64_tm_nsRecvEndNanosecond Epoch request considered complete
uint64_tm_nsSendBegNanosecond Epoch response transmission began
uint64_tm_nsSendEndNanosecond Epoch response transmission ended
void*m_pEventHdlHTTP Event instance
hzIpConnInfo*m_pInfoConnection specific information
hzLogger*m_pLogLog channel
hzIpConnex*m_pProxyProxy connection
SSL*m_pSSLSSL session info