Fortinet white logo
Fortinet white logo

TCP commands

TCP commands

TCP commands can be used in HTTP and TCP events.

TCP:local_port()

Return local TCP port of the connection. The value is integer.

Syntax
TCP:local_port()
Arguments

N/A

Events

Applicable in events HTTP_REQUEST, HTTP_RESPONSE, HTTP_DATA_REQUEST, HTTP_DATA_RESPONSE, CLIENT_ACCEPTED, CLIENT_CLOSED, SERVER_CONNECTED and SERVER_CLOSED.

Example
when HTTP_REQUEST {
    debug("local port%s”, TCP:local_port())
}

TCP:remote_port()

Return remote TCP port of the connection. The value is integer.

Syntax
TCP:remote_port()
Arguments

N/A

Events

Applicable in events HTTP_REQUEST, HTTP_RESPONSE, HTTP_DATA_REQUEST, HTTP_DATA_RESPONSE, CLIENT_ACCEPTED, CLIENT_CLOSED, SERVER_CONNECTED and SERVER_CLOSED.

Example
when HTTP_REQUEST {
    debug("remote port%s”, TCP:remote_port())
}

TCP:client_port()

Return client TCP port of the connection. The value is integer.

Syntax
TCP:client_port()
Arguments

N/A

Events

Applicable in events HTTP_REQUEST, HTTP_RESPONSE, HTTP_DATA_REQUEST, HTTP_DATA_RESPONSE, CLIENT_ACCEPTED, CLIENT_CLOSED, SERVER_CONNECTED and SERVER_CLOSED.

Example
when HTTP_REQUEST {
    debug("client port%s”, TCP:client_port())
}

TCP:server_port()

Return server TCP port of the connection. The value is integer. If the server is not connected, return nil.

Syntax
TCP:server_port()
Arguments

N/A

Events

Applicable in events HTTP_REQUEST, HTTP_RESPONSE, HTTP_DATA_REQUEST, HTTP_DATA_RESPONSE, CLIENT_ACCEPTED, CLIENT_CLOSED, SERVER_CONNECTED and SERVER_CLOSED.

Example
when HTTP_REQUEST {
    debug("server port%s”, TCP:server_port())
}

TCP:close()

Close current TCP connection and disable its TCP events. This function can only be used in event SERVER_CONNECTED.

Syntax
TCP:close()
Arguments

N/A

Events

Applicable in event CLIENT_ACCEPTED

Example
when SERVER_CONNECTED {
    debug("TCP_CLOSE")
    TCP:close()
}

TCP commands

TCP commands

TCP commands can be used in HTTP and TCP events.

TCP:local_port()

Return local TCP port of the connection. The value is integer.

Syntax
TCP:local_port()
Arguments

N/A

Events

Applicable in events HTTP_REQUEST, HTTP_RESPONSE, HTTP_DATA_REQUEST, HTTP_DATA_RESPONSE, CLIENT_ACCEPTED, CLIENT_CLOSED, SERVER_CONNECTED and SERVER_CLOSED.

Example
when HTTP_REQUEST {
    debug("local port%s”, TCP:local_port())
}

TCP:remote_port()

Return remote TCP port of the connection. The value is integer.

Syntax
TCP:remote_port()
Arguments

N/A

Events

Applicable in events HTTP_REQUEST, HTTP_RESPONSE, HTTP_DATA_REQUEST, HTTP_DATA_RESPONSE, CLIENT_ACCEPTED, CLIENT_CLOSED, SERVER_CONNECTED and SERVER_CLOSED.

Example
when HTTP_REQUEST {
    debug("remote port%s”, TCP:remote_port())
}

TCP:client_port()

Return client TCP port of the connection. The value is integer.

Syntax
TCP:client_port()
Arguments

N/A

Events

Applicable in events HTTP_REQUEST, HTTP_RESPONSE, HTTP_DATA_REQUEST, HTTP_DATA_RESPONSE, CLIENT_ACCEPTED, CLIENT_CLOSED, SERVER_CONNECTED and SERVER_CLOSED.

Example
when HTTP_REQUEST {
    debug("client port%s”, TCP:client_port())
}

TCP:server_port()

Return server TCP port of the connection. The value is integer. If the server is not connected, return nil.

Syntax
TCP:server_port()
Arguments

N/A

Events

Applicable in events HTTP_REQUEST, HTTP_RESPONSE, HTTP_DATA_REQUEST, HTTP_DATA_RESPONSE, CLIENT_ACCEPTED, CLIENT_CLOSED, SERVER_CONNECTED and SERVER_CLOSED.

Example
when HTTP_REQUEST {
    debug("server port%s”, TCP:server_port())
}

TCP:close()

Close current TCP connection and disable its TCP events. This function can only be used in event SERVER_CONNECTED.

Syntax
TCP:close()
Arguments

N/A

Events

Applicable in event CLIENT_ACCEPTED

Example
when SERVER_CONNECTED {
    debug("TCP_CLOSE")
    TCP:close()
}