std::vector< char > buffer; // par ex buffer.push_back(0x45) // 1er octet buffer.push_back(0x05) // 2e octet .... SendBytes(buffer);
//SENDLINE void Socket::SendLine(std::string s) { s += '\n'; send(s_,s.c_str(),s.length(),0); }
//RECEIVELINE std::string Socket::ReceiveLine() { std::string ret; //Infinite loop while (1) { char r; //switch(variable) switch(recv(s_, &r, 1, 0)) //Descriptor that identifies a connected //socket, a pointer to the buffer to receive incomming data (r adress), //length in bytes of the buffer pointed,a set of flag that influence the //behavior of this function. { case 0: //If recv retiurn 0 the connection is close // not connected anymore; // ... but last line sent // might not end in \n, // so return ret anyway. return ret; case -1://Error managment return ""; // if (errno == EAGAIN) { // return ret; // } else { // // not connected anymore // return ""; // } }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question//SENDBYTES void Socket::SendBytes(std::vector< char > p) { send(s_,p,p.size(),0); } std::vector< char > Socket::ReceiveLine() { std::vector< char > ret; //Infinite loop while (1) { char r; //switch(variable) switch(recv(s_, &r, 1, 0)) //Descriptor that identifies a connected //socket, a pointer to the buffer to receive incomming data (r adress), //length in bytes of the buffer pointed,a set of flag that influence the //behavior of this function. { case 0: //If recv retiurn 0 the connection is close // not connected anymore; // ... but last line sent // might not end in \n, // so return ret anyway. return ret; case -1://Error managment return std::vector< char >NULL; // if (errno == EAGAIN) { // return ret; // } else { // // not connected anymore // return ""; // } }
std::vector< char > Socket::ReceiveLine() {