note 19032 added to function.socket-create
| From: | email at NOSPAMrichard-samar dot de | Date: | Wed, 13 Feb 2002 18:10:21 +0000 |
| Subject: | note 19032 added to function.socket-create | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-26569@lists.php.net to get a copy of this message | ||
Actually, you don't need to use
getprotobyname("tcp") but instead can use
the constants: SOL_TCP and SOL_UDP.
Here an extract of the source from
ext/sockets which should make this clear.
if ((pe = getprotobyname("tcp"))) {
REGISTER_LONG_CONSTANT("SOL_TCP", pe->p_proto,
CONST_CS | CONST_PERSISTENT);
}
Normally the third parameter can be set to 0. In the
original BSD Socket implementation the third parameter
(there are 8 different types, here only two) should be
IPPROTO_TCP or IPPROTO_UPD (or one of the 6 others ones).
These two parameters are though not warpped in PHP as
constants and therefore not available.
Please use SOL_TCP and SOL_UDP. e.g.:
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
Please be aware of the fact that UDP
and TCP can only be used with AF_INET which is: "Adress Family Internet". With UNIX Domain
sockets TCP/UDP would make no sense!
best regards
-Richard-Moh Samar
--
http://www.php.net/manual/en/function.socket-create.php
http://master.php.net/manage/user-notes.php?action=edit+19032
http://master.php.net/manage/user-notes.php?action=delete+19032
http://master.php.net/manage/user-notes.php?action=reject+19032