Is it possible to bind to a socket with in-browser javascript code? I need to open a local web server when a user visits a page to provide some localhost web publishing.
-
en.wikipedia.org/wiki/WebSocketChaosphere2112– Chaosphere21122011-12-19 19:56:29 +00:00Commented Dec 19, 2011 at 19:56
-
@omnosis - thank you, this is a very important point, that WebSockets only allow outbound connections. I will go ahead and use Silverlight to host an in-page localhost-available web server. You should post your comment as an answer.Maxim V. Pavlov– Maxim V. Pavlov2011-12-19 21:08:54 +00:00Commented Dec 19, 2011 at 21:08
2 Answers
you cannot listen on a port with websocket so you cannot create a local web server within a browser.
Do websockets allow for p2p (browser to browser) communication?
But you can create javascript server with Nodejs. This is also javascript, but not in the browser. This is easy, fast and lightweight.
(i guess) javascript, silverlight, flash cant create in-browser server. they cant access to the sockets directly. the browser not allows. i think the websockets are forwarded sockets by the browser. also i dont really understand why you want to create this.
1 Comment
Modern browsers can use WebSockets, though it has it's own protocol. Otherwise, there are solutions out there that use a hidden Flash object to do TCP sockets. One of them is jsxmlsocket.