What you are requesting is server sockets. For Chrome, the answer is no, Chrome extensions can only open client connections. Firefox extensions, on the other hand, can use the nsIServerSocket
interface to listen for incoming TCP connections on the port. If you are using the Add-on SDK , you will need to use the chrome
package . Something like that:
var {Cc, Ci} = require("chrome"); var socket = Cc["@mozilla.org/network/server-socket;1"] .createInstance(Ci.nsIServerSocket); socket.init(12345, false, -1); socket.asyncListen({ onSocketAccepted: function(socket, transport) { ... }, onStopListening: function(socket, status) { } });
source share