phpsocketsphp-socket

How can send json in telnet to PHP socket


How can i send a json encode string in telnet .

Im using SOCKET and connecting to socket via :

telnet 127.0.0.1 9000

So how i can send request that obtain below code requrments ?

my php code is :

        $received_text = unmask($buf); //unmask data
        $tst_msg = json_decode($received_text); //json decode 
        $user_id = $tst_msg->id; //sender id
        $reciver_id = $tst_msg->rec; //sender name
        $user_message = $tst_msg->message; //message text

Solution

  • you can send your message like this :

    {"id" : "" , "rec" : "" , "message" : ""}