And as a bonus since allegro is so awesome there might be a future when minisphere get's a more decent engine like V8, but in the meantime this simply seems good enough.
var socket = OpenAddress("www.google.com", 80);while (!socket.isConnected()) FlipScreen();socket.write(CreateByteArrayFromString("GET / HTTP/1.1\r\nHost: www.google.com\r\n\r\n"));while (socket.getPendingReadSize() == 0) FlipScreen();Abort(CreateStringFromByteArray(socket.read(socket.getPendingReadSize())));
Ignore me on the finished receiving thing. I didn't do enough research into how sockets work to realize that there was no built-in facility for the receiver to know when the other end has sent a full response (for instance, a full HTML doc), it's just an open data channel....and yes, that means I somehow successfully implemented networking without knowing a thing about how sockets work. As for SCons, can I cherry-pick only the SCons stuff somehow? The rest of the commits in that pull would probably be a very bad idea to merge in at this point. I may just have to close the pull and import them manually.
Threads.doWith({ socket: ListenOnPort(80) }, function() { if (this.socket.isConnected()) { var text = GetVersionString(); var data = CreateByteArrayFromString("HTTP/1.1 200 OK\r\nContent-Length: " + text.length + "\r\n\r\n" + text); this.socket.write(data); this.socket.close(); this.socket = ListenOnPort(80); } return true; });
At this point I have to recommend Sphere developers use minisphere over vanilla Sphere if possible. Only a few APIs are unimplemented (particularly oddball stuff like color matrices), and minisphere is not only faster, but in my testing at least, less glitchy than Sphere 1.5.