Skip to content

Create an example of integration of html and sockets

Goals

The goal is to control a program from html pages.

  1. We want to have a button and a label in a html page.
  2. When button gets clicked, a command json object is sent to an external program
  3. The program receives the object, extract data and sends an answer (same json object) to the html pages which show the result in another label

Json object

  • contains the string of a command ("SAY")
  • contains a string argument of the command (the input label content first, and the answer's data later)

External program

  • Can be a python script listening on a socket connection, whose IP and port is known to the php code in the html