“Real” Javascript Sockets!

I could not find a single way to have real sockets in Javascript. Google told me that there probably is no solution except embeding a java applet or an active-x component! So I thought why not using a little .swf file as a bridge from javascript to the socket functions of flash!

You can see the result here: http://dev.dschini.org/socketjs/

This works pretty neat, fast and stable! The client connects to a patched (”\0\n”) Unreal IRCD. Except connecting and joining a channel there is no much functionality, but it works pretty good!

If you are interested then get your version at http://thinkforge.org!

16 Gedanken zu ““Real” Javascript Sockets!

  1. Sockets from JavaScript? Is this idea not frightening to anyone else? Am I the only one who thinks maybe there are some things JavaScript was never meant to do?

    Although, considering you had to mix in Flash, I guess JavaScript can’t really do sockets… still… *shiver*

    • Do you shiver at Flash doing it? If Flash, which is easily reverse engineered, should be capable of it, why not JavaScript? For me, the idea’s actually pretty exciting, because I can keep all the constraints in the server and cut out the middleman of Perl for most things.

    • Simply put, web apps are the future: they’re relatively easy to build, implement and distribute; they’re os and hardware independant; and they’re becoming more and more powerful. With HTML 5 on the horizon the need for third party (corporate) contolled plugins like flash and silverlight could even drop away… leaving the technology in the hands of the developers themselves rather than some beaurocratic organization. That’s the goal.

  2. @michael
    javascript has had sockets for quite some time, its called xmlhttprequest which makes a socket connection back to the server.

    As long as the sandbox only allows it to connect to the originating server just as in xmlhttprequest then it poses the same security risk as ajax apps.

    the title of this article is misleading as its not a true javascript solution. Firefox allows true javascript sockets via extensions. Otherwise you could have just used all flash to do the same thing that a million sites are already doing with flash sockets.

  3. Hi! Cool library you’ve created.

    You should use the dojo.flash layer to do your JavaScript/Flash communication, which I use on my Dojo Storage library. Here’s what you get if you use Dojo Flash:

    * Support across IE, Firefox, and Safari
    * Fast, Fast, Fast transfer both ways across the boundry
    * Reliable transfer of data that won’t get corrupted by things such as the serialization bugs in ExternalInterface, for example
    * Automatic installation and upgrade of Flash on the browser to work correctly
    * Best of all, you don’t have to roll this stuff yourself :) Plus theres alot more of cool stuff it does for you (for example, it lets you feel like your calling methods from both sides, rather than using the cryptic fscommands and SetVariable ways of doing things)

    Fast, reliable, cross-browser/platform Flash/JS communication is alot harder than Macromedia admits; Dojo Flash makes it easier. Email me if you have questions.

    Best,
    Brad Neuberg
    Dojo Storage/Dojo Flash Maintainer

  4. This must be older, cause it doesn’t work for me in either browser. I have been trying to get this to work for ages on my own. But cannot get the flash to connect once inside a web page. Stand-alone the exe or swf works fine from any machine and connects. But when embedding the flash into a web page, it fails to connect every time. If this has worked in the past PLEASE email me how you got it to work. Thanks

Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *

Du kannst folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">