Possible to open a listening socket? How?

1,975 views
Skip to first unread message

Peter Valdemar Mørch

unread,
Jun 1, 2011, 2:16:25 AM6/1/11
to Chromium-extensions
Hi all,

I want to create a extension, so that during developing web pages, a
save in my editor causes a refresh in the browser. (A trigger, not
just a Chrome periodical refresh). For that I need to send Chrome a
message that it needs to refresh the page. So Chrome needs to open a
TCP socket to listen for such messages in my extension.

The "extension socket" [1] thread suggests WebSockets, but also says:
> Note that websockets won't let you listen to an arbitrary port or open
> regular sockets

I've looked at the WebSockets API [2], but it doesn't seem to allow
opening a listening socket on any ports, even if I'm willing to accept
a limited port set and the WebSocket protocol.

Can I use WebSockets somehow that I've missed or is there another way
to open a listening socket in Chrome without resorting to NPAPI with
all the cross-platform issues that is likely to cause?

Peter

1: http://groups.google.com/a/chromium.org/group/chromium-extensions/browse_thread/thread/d8638fc366a541c2/061c8b91c8a235fa
2: http://dev.w3.org/html5/websockets/#the-websocket-interface

Arne Roomann-Kurrik

unread,
Jun 6, 2011, 2:12:48 PM6/6/11
to Peter Valdemar Mørch, Chromium-extensions
Websockets are designed to allow opening a persistent connection to a server in order to receive and send messages between the browser and a server.  If you're willing to accept the port and protocol restrictions, what problems are you running up against?

~Arne



--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.


Arne Roomann-Kurrik

unread,
Jun 6, 2011, 2:56:47 PM6/6/11
to Peter Valdemar Mørch, Chromium-extensions
Then I'd suggest proxying through a websockets server - have the browser connect to the websockets server, and then have the server ping the browser whenever a reload needs to occur.  Your editor would then send pings to the server to trigger this message.

Otherwise, you could wait to see how the P2P parts of WebRTC look: https://sites.google.com/site/webrtc/ but that's a bit further in the future.

~Arne



On Mon, Jun 6, 2011 at 11:21 AM, Peter Valdemar Mørch <pmo...@gmail.com> wrote:
Thanks Arne, for your reply!


On Mon, Jun 6, 2011 at 8:12 PM, Arne Roomann-Kurrik <kur...@chromium.org> wrote:
Websockets are designed to allow opening a persistent connection to a server in order to receive and send messages between the browser and a server.  If you're willing to accept the port and protocol restrictions, what problems are you running up against?

I want to open a _listening_ socket so that others can connect to the _browser_. Be the server side of a TCP/IP connection as in http://en.wikipedia.org/wiki/Berkeley_sockets#Server

I'm not interested in opening a socket to some socket given by a URL. I want to the *browser* to be the server... (So that it can accept commands in a Chrome version of "Remote Control" https://addons.mozilla.org/en-US/firefox/addon/remote-control/)

Peter

Peter Valdemar Mørch

unread,
Jun 15, 2011, 2:56:43 AM6/15/11
to Chromium-extensions
Apparently it is possible to do exactly what I'm looking for, just
much more elaborately. Its called "Remote Debugging" [1]!

This thread started out as a request to open a general purpose
listening thread where chrome acts as the server side of the
connection, but the purpose was to implement a chrome flavour of my
Firefox "Remote Control" addon [2] - basically "remote-debugging ultra-
lite". I'll just use Remote Debugging [1] instead.

BTW: I still don't think it is possible to solve the general case I
was asking about: Opening a listening/server socket. But my particular
itch instance has been scratched.

[1]: http://code.google.com/chrome/devtools/docs/remote-debugging.html
[2]: https://addons.mozilla.org/en-US/firefox/addon/remote-control/

Peter
Reply all
Reply to author
Forward
0 new messages