I am currently developing a firefox add-on, which is a client that connects via TCP sockets to the server.
In my little testing everything works fine, the client (ff add-on) connects to the server (developed in Java) and sends a message, but after that firefox closes the socket.
I know that this is not a problem with my server-side code, since I can connect to other clients (developed in Java and C ++), and they never close the connection.
I think the problem is that firefox destroys the socket object after there is no link to it to close the connection.
Anyway, here is my code:
const {Cc,Ci} = require("chrome"); var host="192.168.1.100"; var port=9001; var transport = Components.classes["@mozilla.org/network/socket-transport-service;1"] .getService(Components.interfaces.nsISocketTransportService) .createTransport(null, 0, host, port, null); var inputStream = transport.openInputStream(0, 0, 0); var inputInterface = Components.classes["@mozilla.org/binaryinputstream;1"].createInstance(Components.interfaces.nsIBinaryInputStream); inputInterface.setInputStream(inputStream); var outputStream = transport.openOutputStream(0, 0, 0); var outputInterface = Components.classes["@mozilla.org/binaryoutputstream;1"].createInstance(Components.interfaces.nsIBinaryOutputStream); outputInterface.setOutputStream(outputStream); var msg="some message"; outputInterface.writeUtf8Z(msg);
I am using firefox 7 and I am creating an add-in using the SDK for Firefox.
Any ideas on how to keep the outlet alive for further reading?
thanks
source share