Chatting with a server

Pedro Lacerda pslacerda at gmail.com
Mon Feb 13 21:00:14 PST 2012


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20120214/a928183e/attachment.html>


More information about the Digitalmars-d-learn mailing list