FINCLOSE and NOFINCLOSE (JANUS DEFINE parameters)

From m204wiki
Jump to navigation Jump to search

Sockets close-connection characteristics

FINCLOSE and NOFINCLOSE are parameters on JANUS DEFINE, which defines and sets characteristics of a Janus port.

These parameters affect how Janus Sockets applications respond to a closed connection. If the remote host closes the connection, even if it does so "cleanly" (that is with FIN rather than RESET), Janus Sockets closes the connection immediately. This is useful in situations where FIN is as good as RESET for rendering a connection unusable, and where it's important to know that a FIN has been sent to avoid wasted processing or even a hung connection.

If FINCLOSE is not specified, or if NOFINCLOSE is specified, a Janus Sockets thread remains in-use and does not recognize a FIN indicator sent by a remote partner until the Janus Sockets application tries to receive data on the connection.

A situation where FINCLOSE processing is useful is a Janus Sockets application communicating with a web server that is using a keep-alive facility (multiple requests over the same TCP/IP connection). The web server could close the connection between any pair of requests with a FIN. Without FINCLOSE processing, a Janus thread that connected to the web server and received such a FIN would remain in use until the Janus Sockets application tried to receive data on the connection and then noticed the closed connection.

If not set on the port definition, you can make FINCLOSE or NOFINCLOSE specific to a $Sock_Conn call or to a Socket object New constructor.

The FINCLOSE and NOFINCLOSE parameters are valid only for CLSOCK and SRVSOCK ports.

See also