int connection::readline(){ char temp[512],temp2[512]; int mark=0; char *saveptr; int bytes=1; bytes=recv(this->fd,temp2,512,MSG_PEEK); temp2[bytes]=0; if ((temp2[0]=='\r') || (temp2[0]=='\n')){ bytes=recv(this->fd,temp,1,0); //printf("skiped char 0x%x\n",temp2[0]); return 1; } //printf("%s\n",temp2); mark=strcspn(temp2,"\n\r"); temp2[mark]='X'; //printf("%s\n",temp2); bytes=recv(this->fd,temp,mark,0); temp[bytes]=0; //printf("got '%s'\n",temp); this->parse(temp); return bytes; }