PhpDig.net

What is PhpDig?
PhpDig is a PHP MySQL based
Web Spider & Search Engine.




socket_get_status

Name

socket_get_status — Gets information about an open socket descriptor.

Synopsis

array socket_get_status(socket_descriptor);
resource socket_descriptor: Existing socket descriptor returned by fsockopen() or pfsockopen()

Returns

Array containing information on the socket; NULL on error

Description

socket_get_status() is used to retrieve status information on a socket descriptor returned by fsockopen() or pfsockopen() . The information is returned in a four-element associative array with the elements described in the following table.

Key Value
blocked Boolean TRUE if the socket is in blocking mode; FALSE if the socket is in non-blocking mode
eof Boolean TRUE if an EOF was encountered; FALSE otherwise
timed_out Boolean TRUE if the connection is timed out; FALSE otherwise
unread_bytes Integer value indicating the number of bytes left in the socket buffer


Version

PHP Version: 4.0b4+

Example

Example 845. Find the status of an open socket descriptor

<?php
$host = 'www.newriders.com';
$port = 80;

$socket_descriptor = fsockopen($host, $port, &$err_no, &$err_msg, 10)
    or die ("Could not open a socket to host <i>$host</i> on port <i>$port</i>.
        The error message returned was '<i>$err_msg</i>'.");

socket_set_blocking ($socket_descriptor, FALSE)
    or trigger_error ('Socket blocking could not be disabled.');

$status = socket_get_status ($socket_descriptor);
foreach ($status as $key => $value) {
    if (is_bool ($value))
        $value = $value ? 'TRUE' : 'FALSE';
    printf ('%12s: %s<br>', $key, $value);
}
?>



PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/). The authors of this book have elected not to choose any options under the OPL. This online book was obtained from http://www.fooassociates.com/phpfer/ and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.