PHP stream_socket_shutdown() Function
The PHP stream_socket_shutdown() function shutdowns a full-duplex connection. The associated buffer, or buffers, may or may not be emptied.
Syntax
stream_socket_shutdown(stream, mode)
Parameters
stream |
Required. Specify an open stream (opened with stream_socket_client(), for example). |
mode |
Required. Specify one of the following constants:
|
Return Value
Returns true on success or false on failure.
Example: stream_socket_shutdown() example
The example below shows the usage of stream_socket_shutdown() function.
<?php $server = stream_socket_server('tcp://127.0.0.1:1337'); $client = stream_socket_client('tcp://127.0.0.1:1337'); var_dump(fputs($client, "Hello World")); stream_socket_shutdown($client, STREAM_SHUT_WR); //This will not work now var_dump(fputs($client, "Hello World")); ?>
The output of the above code will be:
int(11) PHP Notice: fputs(): send of 11 bytes failed with errno=32 Broken pipe in Main.php on line 10 int(0)
❮ PHP Streams Reference