I am trying to send some data from Firefox to a java desktop application. So my java class works as a server, and the Firefox script works as a client. When I test it using another java class that is client.javadata successfully sent to server.java, when ever, when I use this firefox script to send data, it actually connects to the .but server does send("text");not work in real time. I mean sever shows the received data when I close the socket socket.close();. but I know server.javathere is no problem with the code .
this does not work
setTimeout(function(){socket.send("i'm firefox");},5000);
this job
setTimeout(function(){socket.send("i'm firefox");},5000);
setTimeout(function(){socket.close();},6000);
but I really don't want to close the socket because I want to send a lot of data one by one.
here is the full code tested on notepad [-browser]
var tcpSocket = Cc["@mozilla.org/tcp-socket;1"].createInstance(Ci.nsIDOMTCPSocket);
var socket = tcpSocket.open("127.0.0.1", 5000);
setTimeout(function(){socket.send("i'm firefox");},5000);
I think java code doesn't matter. but here it is.
I ask, why do I need to close the socket to send data? and how can I send data without closing the socket?
updateI made a Gif to show my problem here, you can see data not sending in real time, but when the socket is closed, all data is reset.

source
share