I'm trying to convert a PHP function into a jQuery function so that I can use a TCP/IP socket local connection straight from the browser.
I use this:
$socket = @fsockopen('xxx.xxx.xxx.xxx', '8810', $err_no, $err_str);
if(!$socket){
return 'Errore #'.$err_no.': '.$err_str;
}else{
fwrite($socket, '["D";"C";"?ST";200]');
$read = fread($socket, 2024);
//other stuff...
return $read;
fclose($socket);
}
This works fine. I then downloaded the Github jQuery Websocket 0.0.4 from the Google Code site and followed the example but not successfully.
I just simply tried to make a connection and send data this way:
ws = $.websocket("ws://95.110.224.199:8810/");
ws.send('string', '["D";"C";"?ST";200]');
This gives me "undefined is not a function" error.
I then tried to see if the connection was actually establishing (without sending data) this way:
var ws = $.websocket("ws://xxx.xxx.xxx.xxx:8810/", {
open: function() {console.log('WS:connesso')},
close: function() {console.log('WS:chiuso')},
});
No luck for me... the console says nothin'... Any hint or help on this? Any help is appreciated.