Re: minisphere 1.0b2
Reply #160 –
So I see what you mean about the lack of any kind of Accept() function for listening sockets. As it's implemented in Sphere, a socket created via ListenOnPort is literally replaced by the first thing to connect to it, meaning trickery like this is required to run an actual server:
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;
}
);
(Also, let's just take a moment to appreciate how awesome the Specs threader is.
)