All pastes #53589 Raw Edit

Mine

public cpp v1 · immutable
#53589 ·published 2006-05-04 20:30 UTC
rendered paste body
int client::parse(int msg){   int bytes=0;   int tmp=0;   string buffer="";   string s, p;   char tmpc[4096], sent[100];   int j=0, len=0;    for (;;)    {      bytes = 0;      if ((bytes = recv(sock, tmpc, 4095, 0)) < 1) die("failed recieve bytes form server");       tmpc[bytes] = 0;      buffer += tmpc;      if (buffer.find("PING",0) != string::npos)        {          s = buffer.substr(buffer.find(":"),buffer.size ()-1);          p = p + "PONG :" + s + "\0\n";          for (j=0; j < p.length() && j < sizeof (sent) ; j++)              sent[j] = p[j];          sent [j] = 0 ;          len = strlen(sent);          if (send(sock, sent, len,0) != len) die("send error");        }    }}