inet_client_port()

Afunction returning the client port

inet_client_port() is a  system function which returns the IP port number of the current client.

inet_client_port() was added in PostgreSQL 8.0.

Usage

inet_client_port () → integer

inet_client_port() is called without any arguments, and returns the client IP port as an integer, or NULL if the current connection is via a Unix-domain socket.

Change history

Examples

Example output when connected via TCP/IP:

postgres=# SELECT inet_client_port();
 inet_client_port
------------------
            40276
(1 row)

Example output when connected via a Unix-domain socket:

postgres=# SELECT inet_client_port();
 inet_client_port
------------------

(1 row)

Categories

System function

See also

inet_client_addr(), inet_server_port(), pg_stat_get_backend_client_port()