<div>How would you chat with a server? This is my naive attempt:</div><div><br></div><div>class Client {</div><div> Socket socket;</div><div> </div><div> Token fetch() {</div><div> ubyte[1024] buffer; // if more space is needed...</div>
<div> socket.receive(buffer);</div><div> return decode(buffer);</div><div> }</div><div> </div><div> void send(Token tkn) {</div><div> ubyte[] buffer = encode(tkn);</div><div> socket.send(buffer);</div><div>
}</div>
<div>}</div><div><div><br></div><div>It can send and fetch data (encoded tokens) to/from server. But frequently I see network clients using a connection pool or an event loop. I descarted event loops because they looks hard to implement (and libev docs don't let me anywhere).</div>
<div><br></div><div>Do you can guide me on this trouble?</div><div><br></div>Pedro Lacerda<br><br>
</div>