I am using fsockopen()
to send data via TCP to a remote host:
$s = fsockopen($host, $port);
fwrite($s, $data);
fclose($s);
How can I detect afterwards if the connection was closed (with a FIN) or aborted (with a RST) by the remote host?
According to the documentation socket_last_error() and socket_send() can be helpful for you:
socket_send() returns the number of bytes sent, or FALSE on error. socket_last_error() returns the last error on the socket
I believe, that PHP is able to detect if the connection was closed, however not sure about this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With