Friday, 23 August 2013

using socket to communicate a button click event

using socket to communicate a button click event

I have a device or micro-controller i'll call it a mc that I need to
communicate to when a web page button is clicked using sockets.
MC1
<button id ='on1' name='mc1'>On</button>
<button id ='off1' name='mc1'>off</button>
what I am trying to accomplish is when a button is clicked pass the info
to the mc.
Currently I can listens to a port and can write data to the mc as well as
receive data. To do this im starting a file though the server php cli. The
file contains these basic socket functions.
$socket = @socket_create_listen("port#");
$client = socket_accept($socket);
socket_write($client, $msg);
socket_read ($client, 256);
the mc then connect to the server at the port#
Im having difficulties understanding how to bridge the gap between my php
web page with the button and passing the data that the button has been
clicked to the mc.
can i have the file that listens to the port run and then in a seperate
file write to the client?
Thanks JT

No comments:

Post a Comment