On Friday 13 December 2002 21:30, Max Clark wrote:
> I found the socket_create function that is listed as experimental and
> requires a re-compile of php. Is there a built in way to perform this kind
> of test?


Based upon the second example on 
http://www.php.net/manual/en/ref.sockets.php :

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

/* Get the service for TCP-Port 25. */
$service_port = getservbyport (25, 'tcp');

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

/* 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 {
    echo "OK.\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";
}


johannes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to