Is there a way to start the TCP server that will listen port using Firefox WebExtension? I know that exist way to start server with XUL/XPCOM extension, but it is obsolete and will not be supported (deprecated) from November 2017. The same question interests and about google chrome.
2 Answers
No, a Chrome Extension / Firefox WebExtension cannot open a socket to listen.
However, you could have a separate Native Host component that does it for you. It will need to be installed separately.

- 74,770
- 16
- 179
- 206
-
Can I run JS code from WebExtension in tab page context? – Logioniz Sep 20 '17 at 15:45
-
1Sounds like a separate question, but you're looking either for content scripts or [injected scripts](https://stackoverflow.com/questions/9515704/insert-code-into-the-page-context-using-a-content-script). – Xan Sep 20 '17 at 15:47
-
Yes, another question. I want that Native Host component give JS commands to WebExtension and WebExtenstion execute it from page context. Your example on a link executes JS code once. – Logioniz Sep 20 '17 at 16:02
-
I'm afraid you'll need to read up on [extension architecture](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Anatomy_of_a_WebExtension) first. – Xan Sep 20 '17 at 16:03
-
I just ran my eyes through this article 15 minutes before I wrote this topic :-) I correctly understood you that you wanted to say that the answer to my question is under the #Web_content. Should i use *runtime.sendMessage()* and *runtime.onMessage* to implement what i want? – Logioniz Sep 20 '17 at 16:27
-
Now I just want to understand whether it is possible to realize what I want. If possible, I will later read the details of WebExtension and try to understand what I need to do – Logioniz Sep 20 '17 at 16:48
Not yet.
With the removal of XPCOM, add-ons access to UDP and TCP sockets will disappear, which will cause problems for a number of add-ons.
– Adam Roach
This is being tracked at Firefox bug FF#1435798 (libdweb):
It's been discussed and everyone seems to like the idea.
if somebody is motivated to work on this, sketching out a design that meets the requirements outlined above would be the first step.
we are all for a well thought out API and that's the next step for someone to take on.
You can keep an eye on their progress for it, or lend a hand, at the Git repo.
Of course, as the other answerer notes, a native host / buddy software component is the only workaround at this time; you've got to run some kind of privileged/native code to open sockets until or unless libdweb
gets released.

- 658
- 7
- 19