February 14, 2012 Chatting with a server | ||||
---|---|---|---|---|
| ||||
Attachments:
| How would you chat with a server? This is my naive attempt: class Client { Socket socket; Token fetch() { ubyte[1024] buffer; // if more space is needed... socket.receive(buffer); return decode(buffer); } void send(Token tkn) { ubyte[] buffer = encode(tkn); socket.send(buffer); } } 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). Do you can guide me on this trouble? Pedro Lacerda |
Copyright © 1999-2021 by the D Language Foundation