1

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.

artem
  • 46,476
  • 8
  • 74
  • 78
Maxim V. Pavlov
  • 10,303
  • 17
  • 74
  • 174
  • http://en.wikipedia.org/wiki/WebSocket – Chaosphere2112 Dec 19 '11 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 Dec 19 '11 at 21:08

2 Answers2

1

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.

Community
  • 1
  • 1
Alex Turpin
  • 46,743
  • 23
  • 113
  • 145
1

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.

Community
  • 1
  • 1
Gergely Fehérvári
  • 7,811
  • 6
  • 47
  • 74
  • This is always the point. Every good "not-yet" implemented idea rises reaction of a form "I don't know why would you want to implement it", when inquiring about thechincal realization. Silverlight can bind to a socket, javascript with flash can do to. – Maxim V. Pavlov Dec 20 '11 at 12:49