I want an html (or php) page that connects (and hold the connection) to a TCP port of a remote server. Data or events are sent and received using Javascript functions.
## Deliverables
It is okay if the remote server must be the same as the web-server the page is hosted on.
You may use JQuery, AJAX, Flash, or suggest other technologies. I do not want the client to have to installing plug-ins other than very standard one such as Flash or Java.
I must approve any other technology other than JQuery, AJAX, Flash before accepting your bid.
I need these five JavaScript functions:
SendPacketTCP(data);
CallbackTCP (data);
Connected();
ConnectError(cause);
ConnectionClosed(cause);
SendPacketTCP(data) sends the data to the server and return 1 on success and 0 on error.
CallbackTCP(data) is called whenever chr #10 (or zero) is received which is the separator for the data. I prefer the linefeed (chr #10), but chr #0 is also acceptable.
Connected() should be called when the connection is made successfully.
ConnectError(cause) is called when the connection fails, with the cause of the error (string) as argument.
ConnectionClosed(cause) should be called when the connection is lost with the cause (string) as argument.
The purpose is to be able to send the information as fast as possible to the web browser WITHOUT sending requests to the server for updates.
The client only is required. I already have a TCP server. You do not have to provide a TCP server, but be able to test the work without me providing you with a TCP server.
The connection has to be initiated when the page loads.
Whenever the connection is lost, it must attempt to reconnect immediately.
Whenever the connection fails, it must attempt to reconnect every 10 seconds.