<?php
void stream_notification_callback ( int $notification_code,
int $severity,
str $message,
int $message_code,
int $bytes_transferred,
int $bytes_max )
where,
$notification_code = One of the STREAM_NOTIFY_*
notification constants
$severity = One of the STREAM_NOTIFY_SEVERITY_*
notification constants
$message = Passed if a descriptive message
is available for the event
$message_code = Passed if a descriptive message code
is available for the event
$bytes_transferred = If applicable,
the bytes_transferred will be populated
$bytes_max = If applicable,
the bytes_max will be populated
?>
Predefined Constants | ||
Constant | Value | Description |
STREAM_FILTER_READ | 1 | Used with stream_filter_append and stream_filter_prepend to indicate that the specified filter should only be applied when reading |
STREAM_FILTER_WRITE | 2 | Used with stream_filter_append and stream_filter_prepend to indicate that the specified filter should only be applied when writing |
STREAM_FILTER_ALL | 3 | This constant is equivalent to STREAM_FILTER_READ | STREAM_FILTER_WRITE |
PSFS_PASS_ON | 2 | Return Code indicating that the userspace filter returned buckets in $out. |
PSFS_FEED_ME | 1 | Return Code indicating that the userspace filter did not return buckets in $out (i.e. No data available). |
PSFS_ERR_FATAL | 0 | Return Code indicating that the userspace filter encountered an unrecoverable error (i.e. Invalid data received). |
PSFS_FLAG_NORMAL | 0 | Regular read/write. |
PSFS_FLAG_FLUSH_INC | 1 | An incremental flush. |
PSFS_FLAG_FLUSH_CLOSE | 2 | Final flush prior to closing. |
STREAM_USE_PATH | 1 | Flag indicating if the stream used the include path. |
STREAM_REPORT_ERRORS | 8 | Flag indicating if the wrapper is responsible for raising errors using trigger_error during opening of the stream. If this flag is not set, you should not raise any errors. |
STREAM_CLIENT_ASYNC_CONNECT | 2 | Open client socket asynchronously. This option must be used together with the STREAM_CLIENT_CONNECT flag. Used with stream_socket_client. |
STREAM_CLIENT_CONNECT | 4 | Open client socket connection. Client sockets should always include this flag. Used with stream_socket_client. |
STREAM_CLIENT_PERSISTENT | 1 | Client socket opened with stream_socket_client should remain persistent between page loads. |
STREAM_SERVER_BIND | 4 | Tells a stream created with stream_socket_server to bind to the specified target. Server sockets should always include this flag. |
STREAM_SERVER_LISTEN | 8 | Tells a stream created with stream_socket_server and bound using the STREAM_SERVER_BIND flag to start listening on the socket. Connection-orientated transports (such as TCP) must use this flag, otherwise the server socket will not be enabled. Using this flag for connect-less transports (such as UDP) is an error. |
STREAM_NOTIFY_RESOLVE | 1 | A remote address required for this stream has been resolved, or the resolution failed. See severity for an indication of which happened. |
STREAM_NOTIFY_CONNECT | 2 | A connection with an external resource has been established. |
STREAM_NOTIFY_AUTH_REQUIRED | 3 | Additional authorization is required to access the specified resource. Typical issued with severity level of STREAM_NOTIFY_SEVERITY_ERR. |
STREAM_NOTIFY_MIME_TYPE_IS | 4 | The mime-type of resource has been identified, refer to message for a description of the discovered type. |
STREAM_NOTIFY_FILE_SIZE_IS | 5 | The size of the resource has been discovered. |
STREAM_NOTIFY_REDIRECTED | 6 | The external resource has redirected the stream to an alternate location. Refer to message. |
STREAM_NOTIFY_PROGRESS | 7 | Indicates current progress of the stream transfer in bytes_transferred and possibly bytes_max as well. |
STREAM_NOTIFY_COMPLETED | 8 | There is no more data available on the stream. |
STREAM_NOTIFY_FAILURE | 9 | A generic error occurred on the stream, consult message and message_code for details. |
STREAM_NOTIFY_AUTH_RESULT | 10 | Authorization has been completed (with or without success). |
STREAM_NOTIFY_SEVERITY_INFO | 0 | Normal, non-error related, notification. |
STREAM_NOTIFY_SEVERITY_WARN | 1 | Non critical error condition. Processing may continue. |
STREAM_NOTIFY_SEVERITY_ERR | 2 | A critical error occurred. Processing cannot continue. |
STREAM_IPPROTO_ICMP | 1 | Provides a ICMP socket. |
STREAM_IPPROTO_IP | 0 | Provides a IP socket. |
STREAM_IPPROTO_RAW | 255 | Provides a RAW socket. |
STREAM_IPPROTO_TCP | 6 | Provides a TCP socket. |
STREAM_IPPROTO_UDP | 17 | Provides a UDP socket. |
STREAM_PF_INET | 2 | Internet Protocol Version 4 (IPv4). |
STREAM_PF_INET6 | 23 | Internet Protocol Version 6 (IPv6). |
STREAM_PF_UNIX | 1 | Unix system internal protocols. |
STREAM_SOCK_DGRAM | 2 | Provides datagrams, which are connectionless messages (UDP, for example). |
STREAM_SOCK_RAW | 3 | Provides a raw socket, which provides access to internal network protocols and interfaces. Usually this type of socket is just available to the root user. |
STREAM_SOCK_RDM | 4 | Provides a RDM (Reliably-delivered messages) socket. |
STREAM_SOCK_SEQPACKET | 5 | Provides a sequenced packet stream socket. |
STREAM_SOCK_STREAM | 1 | Provides sequenced, two-way byte streams with a transmission mechanism for out-of-band data (TCP, for example). |
STREAM_SHUT_RD | 0 | Used with stream_socket_shutdown to disable further receptions. |
STREAM_SHUT_WR | 1 | Used with stream_socket_shutdown to disable further transmissions. |
STREAM_SHUT_RDWR | 2 | Used with stream_socket_shutdown to disable further receptions and transmissions. |
STREAM_CAST_FOR_SELECT | 3 | Stream casting, for when stream_select is calling stream_cast. |
STREAM_CAST_AS_STREAM | 0 | Stream casting, when stream_cast is called otherwise (see above). |
STREAM_META_TOUCH | 1 | Used with stream_metadata, to specify touch call. |
STREAM_META_OWNER | 3 | Used with stream_metadata, to specify chown call. |
STREAM_META_OWNER_NAME | 2 |
Used with stream_metadata, to specify |
STREAM_META_GROUP | 5 | Used with stream_metadata, to specify chgrp call. |
STREAM_META_GROUP_NAME | 4 | Used with stream_metadata, to specify chgrp call. |
STREAM_META_ACCESS | 6 | Used with stream_metadata, to specify chmod call. |
STREAM_BUFFER_NONE | 0 | No buffering. |
STREAM_BUFFER_LINE | 1 | Line buffering. |
STREAM_BUFFER_FULL | 2 | Full buffering. |
The constants marked with GREEN are meant to be used with stream_socket_pair. Please note that some of these constants might not be available in your system. The STREAM_META_* constants are meant to be used with stream_metadata. |
||
php.net |
<?php
// This code example was taken from the PHP site
function stream_notification_callback($notification_code,
$severity, $message, $message_code,
$bytes_transferred, $bytes_max) {
switch($notification_code) {
case STREAM_NOTIFY_RESOLVE:
case STREAM_NOTIFY_AUTH_REQUIRED:
case STREAM_NOTIFY_COMPLETED:
case STREAM_NOTIFY_FAILURE:
case STREAM_NOTIFY_AUTH_RESULT:
var_dump($notification_code, $severity, $message,
$message_code, $bytes_transferred, $bytes_max);
break;
case STREAM_NOTIFY_REDIRECTED:
echo "Being redirected to: ", $message;
break;
case STREAM_NOTIFY_CONNECT:
echo "Connected...";
break;
case STREAM_NOTIFY_FILE_SIZE_IS:
echo "Got the filesize: ", $bytes_max;
break;
case STREAM_NOTIFY_MIME_TYPE_IS:
echo "Found the mime-type: ", $message;
break;
case STREAM_NOTIFY_PROGRESS:
echo "Made some progress, downloaded ",
$bytes_transferred, " so far";
break;
}
echo "<br>";
}
$ctx = stream_context_create();
stream_context_set_params($ctx,
["notification" => "stream_notification_callback"]);
file_get_contents("https://php.net/contact", false, $ctx);
echo "<br>";
?>