TCP:close()
Allows the user to close the TCP connection immediately. Once an associated session is closed, all the after_timers will be deleted.
Returns Boolean true if successful, otherwise, returns Boolean false.
Syntax
TCP:close();
Arguments
N/A
Events
Applicable in the following events:
-
HTTP events: HTTP_REQUEST, HTTP_RESPONSE, HTTP_DATA_REQUEST, HTTP_DATA_RESPONSE
-
TCP events: TCP_ACCEPTED, SERVER_CONNECTED, SERVER_BEFORE_CONNECT
-
CLIENTSSL_HANDSHAKE
Example
when TCP_ACCEPTED {
AFTER_TIMER_NAME = function ()
debug("[%s]====>After function call begin:\n",ctime());
debug("[%s]====>After function call end.\n",ctime());
end
TCP:after_timer_set("AFTER_TIMER_NAME", 1000, true);
}
when HTTP_REQUEST{
debug("[%s]------> Events: HTTP_REQUEST begin:\n", ctime());
TCP:close();
}
When the client successfully creates a TCP connection, the script will be executed. When the HTTP is requested, the TCP connection will be closed.
Client side:
[root@Client1 ~]# curl http://10.1.0.15 -v * Trying 10.1.0.15:80... * Connected to 10.1.0.15 (10.1.0.15) port 80 (#0) > GET / HTTP/1.1 > Host: 10.1.0.15 > User-Agent: curl/8.0.1 > Accept: */* > * Empty reply from server * Closing connection 0 curl: (52) Empty reply from server
Supported Version
FortiADC version 7.4.1 and later.