Defined in file: hzIpServer.h
Generic client connection
Constructors/Detructors
| hzIpConnex* | hzIpConnex | (hzLogger* pLog) | |
| NULL-TYPE | hzIpConnex | (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_t | CliPort | (void) | |
| uint32_t | CliSocket | (void) | |
| hzIpaddr | ClientIP | (void) | |
| uint32_t | EventNo | (void) | |
| void | ExpectSize | (uint32_t nBytes) | |
| uint32_t | ExpectSize | (void) | |
| uint64_t | Expires | (void) | |
| hzIpConnInfo* | GetInfo | (void) | |
| hzLogger* | GetLogger | (void) | |
| void | Hypoxia | (void) | |
| hzEcode | 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. |
| hzChain& | InputZone | (void) | |
| bool | IsCliBad | (void) | |
| bool | IsCliTerm | (void) | |
| bool | IsVirgin | (void) | |
| bool | MsgComplete | (void) | |
| bool | MsgReady | (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. |
| void | Oxygen | (void) | |
| int32_t | Recv | (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! |
| hzEcode | SendData | (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. |
| hzEcode | SendData | (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. |
| void | SendKill | (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 |
| void | SetInfo | (hzIpConnInfo* pInfo) | |
| void | SetSocket | (uint32_t nSock) | |
| uint32_t | SizeIn | (void) | |
| void | Terminate | (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_t | TimeAcpt | (void) | |
| uint64_t | TimeProc | (void) | |
| uint64_t | TimeRecv | (void) | |
| uint64_t | TimeXmit | (void) | |
| uint32_t | TotalIn | (void) | |
| uint32_t | TotalOut | (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_in | m_CliAddr | IP Addres of client socket | |
| hzIpaddr | m_ClientIP | IP address of client | |
| uint64_t | m_ConnExpires | Nanosecond Epoch expiry | |
| hzChain | m_Input | Incomming message chain | |
| hzChain::Iter | m_MsgStart | For iteration of pipelined requests | |
| hzTcpCode(*)(hzIpConnex*) | m_OnConnect | Optional: Called on connection e.g. Server hello. | |
| hzTcpCode(*)(hzIpConnex*) | m_OnDisconn | Optional: Called on disconnection for any tidying up. | |
| hzTcpCode(*)(hzChain&,hzIpConnex*) | m_OnIngress | Required: Function to handle messages comming in on the specific port. | |
| hzPktQue | m_Outgoing | Outgoing message stream | |
| void* | m_appFn | Application message event handler | |
| bool | m_bAcceptSSL | SSL has been accepted | |
| bool | m_bInitSSL | If there is an SSL conection, has it been accepted and set up? | |
| uint16_t | m_bListen | Operational flags from listening socket (HZ_LISTEN_SECURE | HZ_LISTEN_INTERNET | HZ_LISTEN_UDP) | |
| uint32_t | m_bState | Client state | |
| int | m_nCliLen | Length of socket address | |
| uint32_t | m_nExpected | Expected size of incomming request | |
| uint32_t | m_nGlitch | Extent of incomplete write | |
| uint32_t | m_nMsgno | Event/Message number | |
| uint16_t | m_nPort | Incomimg port | |
| uint32_t | m_nSock | Client socket | |
| uint32_t | m_nStart | Start position of current incomming message within chain | |
| uint32_t | m_nTotalIn | Total size of outgoing response | |
| uint32_t | m_nTotalOut | Total size of outgoing response | |
| uint64_t | m_nsAccepted | Nanosecond Epoch connection accepted | |
| uint64_t | m_nsRecvBeg | Nanosecond Epoch first packet of message | |
| uint64_t | m_nsRecvEnd | Nanosecond Epoch request considered complete | |
| uint64_t | m_nsSendBeg | Nanosecond Epoch response transmission began | |
| uint64_t | m_nsSendEnd | Nanosecond Epoch response transmission ended | |
| void* | m_pEventHdl | HTTP Event instance | |
| hzIpConnInfo* | m_pInfo | Connection specific information | |
| hzLogger* | m_pLog | Log channel | |
| hzIpConnex* | m_pProxy | Proxy connection | |
| SSL* | m_pSSL | SSL session info |