// how to compile : g++ -o client client.cc -lboost_thread -lboost_system #include #include int main() { boost::asio::ip::tcp::endpoint endpoint; endpoint.address(boost::asio::ip::address::from_string("192.168.0.100")); endpoint.port(3000); boost::asio::io_service io_service; boost::asio::ip::tcp::socket sock(io_service); sock.connect(endpoint); char databuf[14] = {10, 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}; char header[8] = {10, 0, 'I', 'R', 'D', 1, 100, 0}; int buflen = 2+8+100*14; char buf[buflen]; buf[0] = 128; buf[1] = 5; for (int i=0; i<8; i++) { buf[i+2] = header[i]; } for (int i=0; i<100; i++) { for (int j=0; j<14; j++) { buf[10+j+i*14] = databuf[j]; } } while (true) { sock.send(boost::asio::buffer(buf,100*14+2+8)); //sleep(1); /* unsigned int len = (unsigned int)(*((unsigned short*)&buf)); char* dbuf = &buf[2]; unsigned int pid = (unsigned int)dbuf[0]; unsigned int sid = (unsigned int)dbuf[1]; std::string response(&buf[2], 3); unsigned int buffno = (unsigned int)dbuf[5]; unsigned int nevents = (unsigned int)(*((unsigned short*)&dbuf[6])); for(unsigned int i=0; i