How to test phpsocket-php Tutorial

Source: Internet
Author: User
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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.