How to test phpsocket
"; Socket_write ($ msgsock, $ msg, strlen ($ msg); echo 'read client message \ n'; $ buf = socket_read ($ msgsock, 8192 ); $ talkback = "received message: $ buf \ n"; echo $ talkback; if (false = socket_write ($ msgsock, $ talkback, strlen ($ talkback ))) {echo "socket_write () failed reason :". socket_strerror (socket_last_error ($ sock )). "\ n";} else {echo 'send success ';} socket_close ($ msgsock);} while (true); // close socketsocket _ Close ($ sock);?>
How can I run this code? I cannot open the page ..
How can I test the result of the socket I wrote ........ I want to test and write the socket client. I just need to enter the URL directly in http... I really don't know how to test the socket ..
Reply to discussion (solution)
Add this file named socket_test.php
Run on the terminal
php socket_test.php
You can.
Test the socket on the terminal!
Add this file named socket_test.php
Run on the terminal
php socket_test.php
You can.
Warning: socket_bind (): unable to bind address [48]: Address already in use in/Applications/XAMPP/xamppfiles/htdocs/socket/index. php on line 14
Socket_bind () failed: reason: Address already in use
An error is reported directly ..
Try another port
Now it's just running. it's just like this. okay ?? How can we test it?