Scott Andrew - lo-fi acoustic pop superhero!

Join the Demo Club to unlock new music, get discounts, tour dates and other neato stuff:

or learn more here.

January 13, 2003

XMLSocket

Speaking of Flash…I’ve been messing around with Flash MX and its support for persistent, two-way streaming connections via the XMLSocket stuff. Interesting point: you can do arbitrary HTTP requests by shoehorning the text of the request into a malformed XML document:

socket = new XMLSocket();

socket.onData = function (src)
{
    trace("\ndata:" + src);
}

if (!socket.connect("my.example.com", 80))
{
    trace ("connect: Connection failed!")
}

var req = "POST /mod_pubsub/demo HTTP/1.0\n" +
    "User-Agent: FlashMX Client (Win2K)\n" +
    "Host: my.example.com\n" +
    "Content-Length: 12\n" +
    "Content-Type: text/plain\n\n" +
    "Hello World!";

var xml = new XML(req);
socket.send(xml);

Through this, I’ve been able to hook up Flash MX to a KnowNow event router (the same should work for mod_pubsub, but I haven’t tested it yet) with varying degrees of success. A small sticking point seems to be that any returned data has to be terminated with a null character (like “%00″) or the data handlers won’t fire. But it’s encouraging to know that you can effectively speak HTTP over XMLSocket without having to speak XML.

No Comments

Leave a Comment

Psst! If you want to change your icon, go get a Gravatar after submitting your comment!

Get The Tunes

Download Scott Andrew tracks from iTunes Find Scott Andrew at Spotify Find Scott Andrew at Amazon Find Scott Andrew at Emusic Find Scott Andrew at Rhapsody Find Scott 
Andrew at CD Baby Find Scott Andrew at Napster Find Scott Andrew at Lala

More Options

Reader Comments

New Videos

More Videos

Photos

More Photos at Flickr