Is it possible to create a browser extension to allow incoming requests?

I want to figure out a way to make an incoming request to the browser. Installing the extension in the browser is fine. The goal of this is to allow another machine to connect to the extension to control the game without requiring an intermediate server.

Is it possible? Is it possible for the Chrome or Firefox extension to open a port to allow an incoming request?

+4
source share
1 answer

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) { } }); 
+2
source

All Articles