Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
tcp server web extension. copy the files from into exapi/tcp
"manifest_version": 2,
"version": "1.0",
"name": "tcp-server-demo",
"description": "tcp server in a web extension",
"permissions": [],
"experiment_apis": {
"TCPSocket": {
"schema": "exapi/tcp/schema.json",
"child": {
"scopes": ["addon_child"],
"paths": [["TCPSocket"]],
"script": "exapi/tcp/Socket.js"
"background": {
"scripts": ["src/main.js"]
const encoder = new TextEncoder
const decoder = new TextDecoder
;(async function (context) {
const server = await browser.TCPSocket.listen({ port: 8090 })
console.log('listening on :8090')
await (async function (server) {
for await (const client of server.connections) {
console.log('CONNECTION', client)
while (true) {
var msg = decoder.decode(await
await client.write(encoder.encode(msg.toUpperCase()).buffer)
console.log('server stopped')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.