Browser Socket Access
Discussions focus on browsers' lack of direct TCP/UDP socket support, reliance on WebSockets or proxies for networking, and security concerns around localhost/private network access from web pages.
Activity Over Time
Top Contributors
Keywords
Sample Comments
I assume you still can't use UDP or bind to TCP sockets that are accessible outside of the browser?
URL requests should go to a OS level, where the user can intercept them at will. We do not need to give browsers the socket API.
We have a need for this at scrimba.com, where we are now developing a way for people to record coding casts with access to local files and your local terminal. We want to let people record from any directory using a simple CLI (you only need to install an npm package). This will start a websocket-server locally, and then open up your browser at scrimba.com - which connects to said socket. This works in chrome since we're allowed to connect to ws://127.0.0.1, but other browsers nee
The browser doesn't provide the usual POSIX api for opening TCP connections. With some work you can write a shim library that implements it in terms of websockets, but it still can't connect to arbitrary hosts. Instead you have to run a proxy server for it to connect to.
How do they get networking and sockets working in the browser? As far as I know, no browsers allow raw network access. Some apps can get around this by using things like a websocket proxy, but this relies on routing your network traffic through a third party. It'd be great to see this solved and to let users host ephemeral network servers from their browsers.
How is this implemented? Is there a feature in the browser that opens a TCP port to receive incoming connections? If so, how can I switch this off?
If only WebSockets allowed for raw TCP/UDP requests in the browser - would bypass the need to connect over a third-party server..
Applications that need to make direct TCP/UDP connections to things, but which you want to run in the browser and don't want to rely on a centralised websockets proxy or other hacks.Endless use-cases for this. Servers, games, collaboration tools, clients for non-HTTP protocols (email, gopher, Gemini etc), file sharing. You name it.
Must be some sort of tunneling, because it works outside the browser too
This is definitely out of scope for web browsers. The security implications of allowing arbitrary sockets are prohibitive.To do something like that then you’re going to need a different environment with a different set of security guarantees and expectations, more like a shell where the user is responsible for vouching for the code’s trustworthiness.