note 99887 added to function.getprotobynumber
| From: | recycling dot sp dot am at gmail dot com | Date: | Mon, 13 Sep 2010 10:40:06 +0000 |
| Subject: | note 99887 added to function.getprotobynumber | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-172506@lists.php.net to get a copy of this message | ||
Note that by the time of writing this note (5.3.3), there seems to be only two defined constants for
the protocol numbers: SOL_UDP and SOL_TCP.
For all other protocols (like ICMP,... ) you'll have to provide the exact number (EG: 1 for
ICMP, ... )
<?php
echo getprotobynumber(SOL_TCP) . "\n"; // prints tcp
echo getprotobynumber(SOL_UDP) . "\n"; // prints udp
var_dump(getprotobyname('tcp') == SOL_TCP); // bool(true)
var_dump(getprotobyname('udp') == SOL_UDP); // bool(true)
?>
On a UNIX system (don't know if this is true for Windows), the php functions getprotobyname and
getprotobynumber are just wrapper for their corresponding system calls. These functions returns the
protocol name or protocol number based on the definition from IANA. If you are looking for a
protocol and you don't know its number, you can find the exact protocol number here: http://www.iana.org/assignments/protocol-numbers
----
Server IP: 217.71.118.166
Probable Submitter: 91.183.8.79
----
Manual Page -- http://www.php.net/manual/en/function.getprotobynumber.php
Edit -- https://master.php.net/note/edit/99887
Del: integrated -- https://master.php.net/note/delete/99887/integrated
Del: useless -- https://master.php.net/note/delete/99887/useless
Del: bad code -- https://master.php.net/note/delete/99887/bad+code
Del: spam -- https://master.php.net/note/delete/99887/spam
Del: non-english -- https://master.php.net/note/delete/99887/non-english
Del: in docs -- https://master.php.net/note/delete/99887/in+docs
Del: other reasons-- https://master.php.net/note/delete/99887
Reject -- https://master.php.net/note/reject/99887
Search -- https://master.php.net/manage/user-notes.php