getprotobyname

int getprotobyname( string protocol_name) 

Gets the standard protocol number for a protocol name.

Returns:

Port number; -1 on error

Description:

getprotobyname() gets the protocol number for the given protocol name on the local system. If the protocol is not recognized, the function returns -1. If you’re looking for service-to-port mapping (in other words, SMTP is port 25), see getservbyname().

Information on the protocol names and corresponding numbers can be found in RFC 1340 and your system’s /etc/protocol or c:\windows\protocol file (if present).

Availability:

UNIX, Windows

Version:

4.0b4+

See also:

getprotobynumber() 

Example:

23.9. Find out what number the UDP protocol is assigned
 $protocol = 'udp'; echo "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.