This week I do some final touch to the PCB board design. (Spartan6 TQFP, PIC32, HC-05).

And then I get my hands on to some programming. My goal is to make a Php server that is able to be ping from my Wt::Client(Ajax) that I previously done. The idea is the same with using a PIC32 MCU to act as a ‘Server’ but now is to use PHP on Linux. Surprisingly the C network programming knowledge that I learn/implemented on microcontroller is exactly the same with PHP.

  1. Open/Accept a socket
  2. Bind a port
  3. Listen socket
  4. Write socket
  5. Close/Disconnect socket

To run a PHP script on Linux

Create a PHP file (example.php) -> Open terminal: $ph example.php

Next is to have Wt::Client(Ajax) ping to this PHP server. It is understood that the IP address here will be ‘localhost’, so in Wt::Client(Ajax) just have ~url: “http://localhost:port”~ then observe the result from either Client side or Server side. The Client method I am using requires a browser to execute, after some testing I realize the PHP Server I implemented is incorrect. because after a single READ/WRITE transaction, PHP Server will come to halt.

The problem is due to the open and close socket, therefore I change the network programming of my PHP to use PHP Stream Server.

$socket = stream_socket_server("tcp://localhost:8181", $errno, $errstr);

With the above implementation, I manage to have a PHP Server communicate with Wt::Client


0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.