Communication problems between php and cPP socket

now the project wants to monitor the identification result of a software and use socket to communicate with the software, but it is found that the result cannot be received and read circularly all the time. Do you have any good solutions?

    $socket = socket_create(AF_INET,SOCK_STREAM,SOL_TCP);
    //
    if(socket_connect($socket,"192.168.31.83",5266) == false){
        echo "connect fail massege:".socket_strerror(socket_last_error());
    }else{
            echo "client write success".PHP_EOL;
            //
            while($callback = socket_read($socket,32768,PHP_BINARY_READ)){
                //socket_getpeername($new_socket, $addr, $port);
                echo "server return message is:".PHP_EOL.$callback;
            }
    }
    socket_close($socket);//
Sep.01,2021

exit the while loop


to make sure that data is returned from the server.

Menu