when i debuged the file following,the error happened:
Fatal error: Call to undefined function: socket() in /user/EMEDIA/webhome/david/sock/sock_client.php on line 13
the file is:
<?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 (AF_INET, SOCK_STREAM, 0);
if ($socket < 0) {
echo "socket() failed: reason: " . strerror ($socket) . "\n";
} else {
"socket() successful: " . strerror ($socket) . "\n";
}
echo "Attempting to connect to '$address' on port '$service_port'...";
$result = connect ($socket, $address, $service_port);
if ($result < 0) {
echo "connect() failed.\nReason: ($result) " . strerror($result) . "\n";
} else {
echo "OK.\n";
}
$in = "HEAD / HTTP/1.0\r\n\r\n";
$out = '';
echo "Sending HTTP HEAD request...";
write ($socket, $in, strlen ($in));
echo "OK.\n";
echo "Reading response:\n\n";
while (read ($socket, $out, 2048)) {
echo $out;
}
echo "Closing socket...";
close ($socket);
echo "OK.\n\n";
?>