getservbyport

mixed getservbyport( int port, string protocol_type) 
port Name of the service
protocol_type Name of the protocol; either tcp or udp

Gets the name of a service running on a port.

Returns: Service name; FALSE on error

Description: getservbyport() returns the name of the service running on a port under the given protocol, as defined in your system’s /etc/services or c:\windows\services file. If the protocol is not recognized, the function returns FALSE.

Availability:

UNIX, Windows

Version:

4.0b4+

See also:

getservbyname() 

Example:

23.12. Find out what service listens on a given port
 <?php $port = 23; $protocol = 'tcp'; $service = getservbyport ($port, $protocol) or die ("No service is assigned to port $port using the $protocol ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.