3 ms·
HTTP is unbeatable when you remove optional headers, not because of bandwidth; but because there are robust servers that can multi-thread joint-memory access w
by bullen 6y ago
HTTP is unbeatable when you remove optional headers, not because of bandwidth;
but because there are robust servers that can multi-thread joint-memory access with non-blocking IO and atomic concurrency.
I use comet-stream for real-time 3D Action MMO data, so I have my own text based protocol wrapped in 2x sockets HTTP:
F.ex. message = "move|<session>|<x>,<y>,<z>|<x>,<y>,<z>,<w>|walk":
### push (client -> server):
"GET /push?data=" + message + " HTTP/1.1\r\nHost: my.host.name",
then you get back
"200 OK\r\nContent-Length: <length>\r\n\r\n<content>". In this case "0\r\n\r\n".
### pull (server -> client):
Just one request pulls infinite response chunks:
"GET /pull HTTP/1.1\r\nHost: my.host.name\r\nAccept: text/event-stream"
then you get back
"200 OK\r\nTransfer-Encoding: chunked\r\n\r\n".
while(true) {
<hex_length> + "\r\n"
"data:" + message + "\n\n\r\n\r\n"
}
Simple and efficient!
Text- + Event- based protocols over HTTP way outscale Binary- + Tick- based ones for compressed (as in averaged, not zipped) real-time data.