I am trying to send and receive data through a PHP socket.
Evrything is fine, but when I try to send data, PHP doesn't send anything (Wireshark told me that the length of the data transferred was 0).
I am using this code:
<?php $address = 'example.com'; $port = 1234; $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); $sockconnect = socket_connect($sock, $address, $port); $c = 0; do { $c++; $msg = '<test>Xml data</test>'; socket_write($sock, $msg, strlen($msg)); echo socket_read($sock, 1024 * 100, PHP_NORMAL_READ); } while ($c < 3); socket_close($sock);
Can anyone help me? Thanks for reading my question.
source share