📄 rpcio.cc
字号:
//// RPCio.cc : RPC Radio Support for Diffusion// Authors : Fabio Silva//// Copyright (C) 2000-2002 by the University of Southern California// $Id: RPCio.cc,v 1.7 2002/06/27 22:04:31 fabio Exp $//// This program is free software; you can redistribute it and/or// modify it under the terms of the GNU General Public License,// version 2, as published by the Free Software Foundation.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License along// with this program; if not, write to the Free Software Foundation, Inc.,// 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.////#include <stdio.h>#include <stdlib.h>#include "RPCio.hh"RPCIO::RPCIO() : DiffusionIO(){ int fd; if ((fd = open(RPC_DEVICE_FILE, O_RDWR)) < 0){ DiffPrint(DEBUG_ALWAYS, "Cannot open the radiometrix device !\n"); exit(-1); } in_fds_.push_back(fd); out_fds_.push_back(fd); max_in_descriptor_ = fd;}DiffPacket RPCIO::recvPacket(int fd){ DiffPacket incoming_packet = NULL; int packet_size; int header[(sizeof(struct hdr_diff) / sizeof(int)) + 1]; read(fd, &header[0], sizeof(struct hdr_diff) | RPC_MSG_PEEK); packet_size = sizeof(struct hdr_diff) + ntohs(DATA_LEN(HDR_DIFF(&header[0]))); incoming_packet = new int [(packet_size / sizeof(int)) + 1]; if (incoming_packet == NULL){ DiffPrint(DEBUG_ALWAYS, "Cannot allocate memory for incoming packet !\n"); exit(-1); } read(fd, incoming_packet, packet_size); return incoming_packet;}void RPCIO::sendPacket(DiffPacket pkt, int len, int dst){ list<int>::iterator itr; for (itr = out_fds_.begin(); itr != out_fds_.end(); ++itr){ write(*itr, pkt, len); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -