Use websocket in js to connect to the printer for printing. the port of the known printer is opened by default. use the PHP code {code ...} this print is acceptable, but only the header information is printed through the websocket connection of JS. what is the situation? The js code is: {code...} js side is not going into... use js to connect to the printer for printing with websocket. it is known that the printer port is opened by default, through PHP code
$s = fsockopen("192.168.1.122", 8081,$errno, $errstr, 30); fwrite($s,"abcjiuejseeeeeeeee2222222222ss");
This print is acceptable, but only the header information is printed through the websocket connection of JS. 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 ("connection successful"); ws. send ('20140901');}; ws. onclose = function (e) {console. log ("connection closed") ;}; ws. onerror = function (e) {console. log ("error ");};
Js cannot access ws. open.
Reply content:
Use websocket to connect to the printer through js for printing. it is known that the port of the printer is opened by default, and PHP code is used.
$s = fsockopen("192.168.1.122", 8081,$errno, $errstr, 30); fwrite($s,"abcjiuejseeeeeeeee2222222222ss");
This print is acceptable, but only the header information is printed through the websocket connection of JS. 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 ("connection successful"); ws. send ('20140901');}; ws. onclose = function (e) {console. log ("connection closed") ;}; ws. onerror = function (e) {console. log ("error ");};
Js cannot access 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 handshaking verification. you can take a look at the three touch hands of the Tcp protocol and the communication between websocket and PHP socket.