Through JS with WebSocket to connect the printer to print, known that the printer port is open by default, through the PHP code
$s = fsockopen("192.168.1.122", 8081,$errno, $errstr, 30); fwrite($s,"abcjiuejseeeeeeeee2222222222ss");
This printing is possible, but through the JS WebSocket connection only print the header information, what is the situation?
The JS code is:
ws = new WebSocket("ws://192.168.1.122:8081/");console.log(ws);ws.onopen = function (e) { console.log(e); console.log("连接成功"); ws.send('2222222222222222222222222222');};ws.onclose = function(e) { console.log("连接关闭");};ws.onerror = function(e) { console.log("出现错误");};
JS here is not going to Ws.open
Reply content:
Through JS with WebSocket to connect the printer to print, known that the printer port is open by default, through the PHP code
$s = fsockopen("192.168.1.122", 8081,$errno, $errstr, 30); fwrite($s,"abcjiuejseeeeeeeee2222222222ss");
This printing is possible, but through the JS WebSocket connection only print the header information, what is the situation?
The JS code is:
ws = new WebSocket("ws://192.168.1.122:8081/");console.log(ws);ws.onopen = function (e) { console.log(e); console.log("连接成功"); ws.send('2222222222222222222222222222');};ws.onclose = function(e) { console.log("连接关闭");};ws.onerror = function(e) { console.log("出现错误");};
JS here is not going to Ws.open
$s = fsockopen("192.168.1.122", 8081,$errno, $errstr, 30);
ws = new WebSocket("ws://192.168.10.120:8081/");
Big Brother, have you found any subtle differences?
192.168.1.122
192.168.10.120
WebSocket is based on the need for handshake verification, you can take a look at the TCP protocol three times and WebSocket and PHP socket communication