receive_data.c

tmi2/lib/adm/daemons/receive_data.c · 590 B

From the archive tmi2_mudos_v1.tar.gz

Download the archive   « Back to the archive contents

// Generic line parser to keep server/clients synced.
// This file should be #included! NOT inheritted. I chose to do
// it this way so that I wouldn't have to use this_object()->parse_line()
// so I could save some CPU time.
// Set unparsed_data = "" just before socket_create()

string unparsed_data;

void parse_line(int fd, string msg);


void receive_data(int fd, string msg)
{
   string parse, rest;

log("RCV: "+fd+"\n"+msg+"\n");
   unparsed_data += msg;

   while(sscanf(unparsed_data,"%s\n%s",parse,rest) == 2)
   {
      unparsed_data = rest;
      parse_line(fd, parse);
   }
}

Site Stats

Snippets: 1791
Codebases: 571