int do_read(char * filename) { int fd; int block; int layout; printf("%s\n",filename); fd = open(filename, O_RDONLY , 0640); if (fd == -1) { printf("proc %3d - open %s %s\n",filename, strerror(errno)); return -1; } layout = do_read_header(fd,1); if (layout == -1) { close (fd); return -1; } block = 0; printf (" offset & block | Time Stamp | relative | length | Pid |Vers.|\n"); printf (" ----------------+----------------------+----------+--------+-----+-----+\n"); while (do_read_block(fd,layout,block) == 0) block++; close(fd); return 0; }
int do_search_start_time(char * filename) { off_t offset = 0; rozofs_stor_bins_hdr_t bins_hdr; size_t nb_read=0; int idx=0; int layout; int fd; fd = open(filename, O_RDONLY , 0640); if (fd == -1) { printf("proc %3d - open %s %s\n",filename, strerror(errno)); return -1; } layout = do_read_header(fd,0); if (layout == -1) { close (fd); return -1; } while (1) { offset = ((rozofs_psizes_max * sizeof (bin_t)+ sizeof(bins_hdr)) * idx++) + ROZOFS_ST_BINS_FILE_HDR_SIZE; nb_read = pread(fd, &bins_hdr, sizeof (bins_hdr), offset); if (nb_read != sizeof (bins_hdr)) return; if ((bins_hdr.s.timestamp==0) && (bins_hdr.s.effective_length==0)) continue; if (start_time > bins_hdr.s.timestamp) start_time = bins_hdr.s.timestamp; } }
void start() { //((Header*)write_header_)->message_id = msgid::fromgate::notify_connection_id; //gr::Notify_Connection_Id msg; //msg.set_connection_id(id_); //msg.SerializeToArray(write_data_, MAX_BODY_LENGTH); //do_write(msg.ByteSize()); do_read_header(); }
void TCPClient::do_read_body(){ boost::asio::async_read(socket_, boost::asio::buffer(read_msg_.body(),read_msg_.body_length()),[this](boost::system::error_code ec,std::size_t){ if(!ec){ //Aquí procesamos el cuerpo del mensaje std::cout.write(read_msg_.body(),read_msg_.body_length()); std::cout<<std::endl; do_read_header(); } }); }
void chat_client::do_connect(asio::ip::tcp::resolver::iterator endpoint_iterator) { asio::async_connect(socket_, endpoint_iterator, [this](std::error_code ec, asio::ip::tcp::resolver::iterator) { if (!ec) { do_read_header(); } }); }
void TCPClient::do_connect(tcp::resolver::iterator endpoint_iterator) { //El conector requiere del socket, el iterador de endpoints y una función de handler. En este caso la función es una función Lambda boost::asio::async_connect(socket_, endpoint_iterator, [this](boost::system::error_code ec,tcp::resolver::iterator){ //Si no hay error. Dinero es Dinero if(!ec) { do_read_header(); } }); }
static void de_run_fnt(deark *c, de_module_params *mparams) { lctx *d = NULL; d = de_malloc(c, sizeof(lctx)); if(!do_read_header(c, d)) goto done; read_face_name(c, d); do_make_image(c, d); done: de_finfo_destroy(c, d->fi); de_free(c, d); }
void do_read_body(Header header){ auto self(shared_from_this()); buf_ptr buf_ptr_(new EasyBuffer); buf_ptr_->prepare(sizeof(Header) + header.body_size); memcpy(buf_ptr_->get_buffer(), &header, sizeof(Header)); boost::asio::async_read(socket_, boost::asio::buffer(buf_ptr_->get_buffer(sizeof(Header)), header.body_size), [this, self, &buf_ptr_](boost::system::error_code ec, std::size_t){ if(!ec){ handle_msg(buf_ptr_); do_read_header(); } } ); }
void do_read_body() { auto self(shared_from_this()); int num; if ((num = recv(m_arg->connectfd, m_read_msg.body(), m_read_msg.body_length(), 0)) == 1) { m_room.leave(shared_from_this()); std::cerr << "Wrong,failed to receive body data\n"; return; } m_room.deliver(m_read_msg); do_read_header(); }
void ChatClient::do_read_body() { boost::asio::async_read(socket_, boost::asio::buffer(read_msg_.body(), read_msg_.body_length()), [this](boost::system::error_code ec, size_t /*length*/) { if (!ec) { std::cout << "\t\t"; std::cout.write(read_msg_.body(), read_msg_.body_length()); std::cout << "\n"; do_read_header(); } else socket_.close(); }); }
void do_read_body() { boost::asio::async_read( socket_, boost::asio::buffer(read_msg_.body(), read_msg_.body_length()), [this](boost::system::error_code ec, std::size_t) { if (ec) { std::cout << ec.message() << "\n"; if (ec != boost::asio::error::operation_aborted) { socket_.close(); } return; } do_read_header(); }); }
void chat_client::do_read_body() { asio::async_read(socket_, asio::buffer(read_msg_.body(), read_msg_.body_length()), [this](std::error_code ec, std::size_t /*length*/) { if (!ec) { std::cout.write(read_msg_.body(), read_msg_.body_length()); std::cout << "\n"; do_read_header(); } else { socket_.close(); } }); }
void connect() { boost::asio::async_connect( socket_, iter_, [this](boost::system::error_code ec, tcp::resolver::iterator) { if (ec) { /// maybe error connection_refused std::cout << ec.message() << "\n"; return; } write(MOCK_MESSAGES[0]); write(MOCK_MESSAGES[1]); do_read_header(); }); }
void do_read_body(Gate_Header header) { auto self(shared_from_this()); boost::asio::async_read(socket_, boost::asio::buffer(body_data_, header.body_size), [this, self, &header](boost::system::error_code ec, std::size_t) { if (!ec) { buf_ptr buf(new EasyBuffer); buf->put(body_data_, header.body_size); std::shared_ptr<GateLogicTaskData> task_ptr_(new GateLogicTaskData); task_ptr_->char_id = header.char_id; task_ptr_->message_id = header.message_id; task_ptr_->connection_id = id_; task_ptr_->buf_ptr_ = buf; task_queue_->push(task_ptr_); do_read_header(); } } ); }
void chat_client::do_connect(tcp::resolver::iterator endpoint_iterator) { boost::asio::async_connect(socket_, endpoint_iterator, [this](boost::system::error_code ec, tcp::resolver::iterator) { if ( !ec) { chat_message msg; msg.setSrvMsg(ServiceMsg::onLogin); msg.body_length(username_.length()+1); std::memcpy(msg.body(), username_.c_str(), msg.body_length()); std::memcpy(msg.body()+msg.body_length(), "\n", 1); msg.encode_header(); write(msg); do_read_header(); } }); }
void ChatClient::do_connect(tcp::resolver::iterator endpoint_iterator) { boost::asio::async_connect(socket_, endpoint_iterator, [this](boost::system::error_code ec, tcp::resolver::iterator) { if (!ec) do_read_header(); }); }
void start() { m_room.join(shared_from_this()); do_read_header(); }
void start(){ do_read_header(); }