php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #14663 Empty packets as result of serialization
Submitted: 2001-12-22 15:50 UTC Modified: 2003-01-21 02:15 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: aragon at phat dot za dot net Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.1.0 OS: Windows NT 4 sp 6a
Private report: No CVE-ID: None
 [2001-12-22 15:50 UTC] aragon at phat dot za dot net
Example code copy/pasted from http://www.php.net/manual/en/html/ref.sockets.html :

<?php
error_reporting (E_ALL);

echo "<h2>TCP/IP Connection</h2>\n";

/* Get the port for the WWW service. */
$service_port = getservbyname ('www', 'tcp');

/* Get the IP address for the target host. */
$address = gethostbyname ('www.php.net');

/* Create a TCP/IP socket. */
$socket = socket_create (AF_INET, SOCK_STREAM, 0);
if ($socket < 0) {
    echo "socket_create() failed: reason: " . socket_strerror ($socket) . "\n";
} else {
    "socket_create() successful: " . socket_strerror ($socket) . "\n";
}

echo "Attempting to connect to '$address' on port '$service_port'...";
$result = socket_connect ($socket, $address, $service_port);
if ($result < 0) {
    echo "socket_connect() failed.\nReason: ($result) " . socket_strerror($result) . "\n";
} else {
    echo "OK.\n";
}

$in = "HEAD / HTTP/1.0\r\n\r\n";
$out = '';

echo "Sending HTTP HEAD request...";
socket_write ($socket, $in, strlen ($in));
echo "OK.\n";

echo "Reading response:\n\n";
while (socket_read ($socket, $out, 2048)) {
    echo $out;
}

echo "Closing socket...";
socket_close ($socket);
echo "OK.\n\n";
?>


When run :

<h2>TCP/IP Connection</h2>
<br>
<b>Warning</b>:  socket_strerror() expects parameter 1 to be long, resource given in <b>/usr/home/aragon/squeakbot/test2</b> on line <b>18</b><br>
Attempting to connect to '209.61.157.217' on port '80'...OK.
Sending HTTP HEAD request...OK.
Reading response:

<br>
<b>Warning</b>:  socket_read() expects parameter 2 to be long, string given in <b>/usr/home/aragon/squeakbot/test2</b> on line <b>38</b><br>
Closing socket...OK.


Regards,
Aragon

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-22 15:58 UTC] mfischer@php.net
Making a documentation problem. Valid sample still have to be written.
 [2001-12-22 16:22 UTC] jan@php.net
the manual page is marked as "EXPERIMENTAL".  so waiting for the extension to become stable wil be the best. fixing the example now just to change it again tomorrow is useless.
 [2002-02-06 12:43 UTC] alindeman@php.net
status -> suspended (waiting till it becomes un-experimental ;)

 [2002-02-06 12:44 UTC] alindeman@php.net
status -> suspended (waiting till it becomes un-experimental ;)

 [2002-06-28 03:17 UTC] derick@php.net
No longer experimental
 [2003-01-21 02:15 UTC] philip@php.net
Although the sockets documentation need some help, this particular bug has been taken care of.  The example was updated and works properly now.

Also note that the socket docs are being rewritten as we speak by jason.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Aug 18 15:01:28 2024 UTC