Question

I am trying to send a package and print it's respond. I can successfully send the package using:

$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_write($socket, $in, strlen($in));

however when I try to get the respond for the same socket it never arrives:

while ($out = socket_read($socket, 2048)) {
    echo $out;
}

I can capture the respond in wireshark so I am guessing somehow it's some configuration in xampp or windows I have to do. I am using XAMPP Version 1.8.2 in windows 7 64 bit

Was it helpful?

Solution

K I found the problem. First of all make sure you close the socket.

   socket_close($socket);

But my problem was the data I was getting was Hex. Somehow you would assume echo, or print_r is able to print the data however it's not so I had to convert the data to ASCI.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top