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

Close
  • E-mail
  • Social Web

Email this page to a friend:

E-mail It

Buy Music

Download Scott Andrew tracks from iTunes Find Scott Andrew at Rhapsody Find Scott Andrew at Amazon Find Scott 
Andrew at CD Baby

New Videos

More Videos

Photos

More Photos at Flickr

Recent Reader Comments

  • Adam Sampson: Excellent; I'll look forward to the release of Sin...
  • michael: Well ain't that a hoot! A couple midwesterners tur...
  • big daddy d: still can't beat the andrew, spaly, jolin "Peace o...
  • big daddy d: good room sound. would you play their again?
  • big daddy d: hey he's driving on the wrong side of the road.