Hello,

I want to make a canvas that I can control from a external socket.

Assume the program listens to port 1234

Then I'd like to send sequences of messages to Port 1234 which would contain commands
to manipulate the canvas

For example (in some syntax)

/add_canvas line X1, Y1, X2, Y2 ...
/add_circle X,Y,R

etc. I'd also like to add things like buttons to the canvas
/add_button X,Y,W,H,"click"

and be sent messages (to the controlling socket) when the user clicks on the button.

Instead of having the entire control of the widget in one place - I'd like to
separate them into a client and server with the server doing the graphics
and the client (on a different machine) doing the control.

I realise that these commands would have to be encoded in some sense (ie as JSON, XML)
and framed (I'm assuming TCP) so to avoid fragmentation I'd need to add some
framing information.

What would be the best way to write this?

Suppose the input commands were JSON containing embedded javascript type canvas
plotting commands - would this be easy to implement? If so How?

Thanks