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 on “XMLSocket”

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

  • dp: "Think of it as a single with bonus tracks. BOOM, ...
  • Dave: $1 for the bonus tracks? BOOM! I'm there.
  • Shelby: you're a phenomenal artist. definitely going on th...
  • Steve Rydz: Great song Scott, good to hear something new. Kee...
  • Volker: Really good song! I am curious about the bonus ver...