[TASK] TCP Server - Multiple Connection

[TASK] TCP Server - Multiple Connection

Postby admin » Wed Oct 18, 2017 5:27 pm

In a previous post , I wire some simple description about TCP and how to create a TCP Server on PHPoC. That example only supports a single TCP connection at the same time.

In this post, I am going to show how to create TCP server on PHPoC, which supports multiple connection at the same time.

1. Make sure that your PHPoC Blue or Black is connected to the Internet.

2. Please download a PSP (PHPoC Support Package) of libraries and examples from PHPoC.

3. Connect PHPoC Blue or Black to your PC via USB cable.

4. Run PHPoC Debugger.

5. Find an example of tcpn_echo_ac in the PSP.
psp_tcpn_files.JPG
psp_tcpn_files.JPG (15.98 KiB) Viewed 68 times


6. Upload init.php and task0.php files to your PHPoC Blue or Black.
※ Note that the init.php and task0.php files should be located in the root folder.
psp_phpoc_files.png
psp_phpoc_files.png (2.22 KiB) Viewed 68 times


7. Modify port number in task0.php file if needed.
psp_tcpn_files.JPG
psp_tcpn_files.JPG (15.98 KiB) Viewed 68 times


8. Upload the task0.php to your PHPoC Blue or Black again.

9. We need some TCP clients to test it. You can you any kind of software/program on PC, smartphone which can create a TCP client and make request to TCP Server on PHPoC. You can also use another PHPoC to create TCP clients for testing.
In this example, I use a Windows-based software, namely ezTerm to create TCP client and connect to TCP server in PHPoC. You can download this software at http://www.eztcp.com/en/download/ezterm.php

10. Open some ezTerm windows and type IP address of PHPoC and port number used in the code and connect

11. Send messages from PC to PHPoC via this software and see the result
psp_tcpn_test.JPG
psp_tcpn_test.JPG (83.54 KiB) Viewed 68 times


PHPoC will send back the same message as received. Therefore, ezTerm software on PC receives the same message as what it sent
Attachments
psp_tcpn_modified.JPG
psp_tcpn_modified.JPG (30.83 KiB) Viewed 68 times
admin
Site Admin
 
Posts: 166
Joined: Mon Jan 20, 2014 4:40 pm

Return to Example

Who is online

Users browsing this forum: No registered users and 1 guest