Example 1 — Look Up TCP and UDP Numbers
Resolve common protocol names. These numbers are standard on nearly all systems.
<?php
echo "tcp=", getprotobyname("tcp"), PHP_EOL;
echo "udp=", getprotobyname("udp"), PHP_EOL; How It Works
- getprotobyname("tcp") reads the system protocol table.
- TCP is protocol number 6 on standard systems.
- UDP is protocol number 17.
- We print both values with clear labels.

