View mode: basic / threaded / horizontal-split · Log in · Help
February 14, 2012
Chatting with a server
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
Top | Discussion index | About this forum | D home