• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ receive_data函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中receive_data函数的典型用法代码示例。如果您正苦于以下问题:C++ receive_data函数的具体用法?C++ receive_data怎么用?C++ receive_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了receive_data函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: handle_data_dl

/*
 * Handle downlink data, ports that are handled are modem and diagnostics
 * Return 1 - ok
 * Return 0 - toggle fields are out of sync
 */
static int handle_data_dl(struct nozomi *dc, enum port_type port, u8 *toggle,
			u16 read_iir, u16 mask1, u16 mask2)
{
	if (*toggle == 0 && read_iir & mask1) {
		if (receive_data(port, dc)) {
			writew(mask1, dc->reg_fcr);
			*toggle = !(*toggle);
		}

		if (read_iir & mask2) {
			if (receive_data(port, dc)) {
				writew(mask2, dc->reg_fcr);
				*toggle = !(*toggle);
			}
		}
	} else if (*toggle == 1 && read_iir & mask2) {
		if (receive_data(port, dc)) {
			writew(mask2, dc->reg_fcr);
			*toggle = !(*toggle);
		}

		if (read_iir & mask1) {
			if (receive_data(port, dc)) {
				writew(mask1, dc->reg_fcr);
				*toggle = !(*toggle);
			}
		}
	} else {
		dev_err(&dc->pdev->dev, "port out of sync!, toggle:%d\n",
			*toggle);
		return 0;
	}
	return 1;
}
开发者ID:ReneNyffenegger,项目名称:linux,代码行数:39,代码来源:nozomi.c


示例2: receive_message

int receive_message(int connection, message_t *m) {
    char param[HEADER_LENGTH];
    
    receive_data(connection, m->header, sizeof(m->header));
    get_parameter(m->header, strlen(m->header), "length", param, sizeof(param));
    m->data_length = atoi(param);

    if (m->data_length) {
        m->data = malloc(m->data_length);
        receive_data(connection, m->data, m->data_length);
    }
    
    return 0;
}
开发者ID:lucat,项目名称:opendcp-1,代码行数:14,代码来源:opendcp_encoder_remote.c


示例3: receive_data

int CSectionsdClient::readResponse(char* data, int size)
{
	struct sectionsd::msgResponseHeader responseHeader;
    receive_data((char*)&responseHeader, sizeof(responseHeader));

	if ( data != NULL )
	{
		if ( responseHeader.dataLength != size )
			return -1;
		else
			return receive_data(data, size);
	}
	else
		return responseHeader.dataLength;
}
开发者ID:GWARDAR,项目名称:OpenPLi-1,代码行数:15,代码来源:sectionsdclient.cpp


示例4: readResponse

bool CSectionsdClient::getNVODTimesServiceKey(const t_channel_id channel_id, CSectionsdClient::NVODTimesList& nvod_list)
{
	if (send(sectionsd::timesNVODservice, (char*)&channel_id, sizeof(channel_id)))
	{
		nvod_list.clear();

		int nBufSize = readResponse();

		char* pData = new char[nBufSize];
		receive_data(pData, nBufSize);
		char* dp = pData;

		CSectionsdClient::responseGetNVODTimes response;

		while( dp< pData+ nBufSize )
		{
			response.service_id = *(t_service_id *) dp;			dp += sizeof(t_service_id);
			response.original_network_id = *(t_original_network_id *) dp;	dp += sizeof(t_original_network_id);
			response.transport_stream_id = *(t_transport_stream_id *) dp;	dp += sizeof(t_transport_stream_id);
			response.zeit = *(CSectionsdClient::sectionsdTime*) dp;		dp += sizeof(CSectionsdClient::sectionsdTime);

			nvod_list.insert( nvod_list.end(), response);
		}
		close_connection();
		return true;
	}
	else
	{
		close_connection();
		return false;
	}
}
开发者ID:GWARDAR,项目名称:OpenPLi-1,代码行数:32,代码来源:sectionsdclient.cpp


示例5: SendPulsesEtc

 int32
 SendPulsesEtc()
 {
     BMessage m(GNASH_PULSE);
     int32 code;
     thread_id sender;
 
     while (true)
     {
         if (B_OK != be_app_messenger.SendMessage(&m))
             return -1;
 
         unsigned int interval =
             _gui->getInterval();
         if (interval == 0)
            interval = 15;
         // interval in miliseconds, 1000 * interval in microseconds
         usleep(1000 * interval);
 
         do {
             code = receive_data(&sender, NULL, 0);
         } while (code == B_INTERRUPTED);
         switch (code)
         {
             case GNASH_SEND_PULSE:
                 break;
             case GNASH_QUITTING:
                 return 0;
             default:
                 return -1;
         };
     }
     return 0;
 }
开发者ID:diocles,项目名称:gnash,代码行数:34,代码来源:haiku.cpp


示例6: receive_data

  void connection::read()
  {
    std::array<char, 1024> buf;

    auto ptr = buf.data();
    auto len = buf.size();
    auto res = ssize_t{0};

    do
    {
      res = socket_.recv(ptr, len, 0);

      if ( res > 0 )
      {
        receive_data(ptr, res);
      }
      else if ( res < 0 )
      {
        if ( socket_.last_error() == ECONNRESET )
        {
          stop();
        }
      }
      else
      {
        stop();
      }
    }
    while ( res != 0 && res == static_cast<ssize_t>(len) );
  }
开发者ID:bebac,项目名称:fuzzy-octo-avenger,代码行数:30,代码来源:connection.cpp


示例7: register_and_load_cluster_nodes

/* register and load cluster nodes */
cluster_t * register_and_load_cluster_nodes(char *addr, int port)
{
    int i;
    int DataNum = -1;
    char Buf[MAX_BUF_LEN] = "\0";
    int BufSize = MAX_BUF_LEN;
    char szMsg[MAX_BUF_LEN] = "\0";
    char ppData[MAX_DATA_NUM][MAX_DATA_LEN] = {0};
    ServiceHandler h = -1;
    // master server's addr and port
    h = open_remote_service(IP_ADDR,PORT);

    if(addr == NULL)
    {
        DataNum = 0;
    }
    else
    {
        DataNum = 1;
        sprintf(ppData[0],"%s %d\0",addr,port);
        debug("pasrer sprintf :%s\n",ppData[0]);     
    }

    format_ctl_data(Buf,&BufSize,CTL_REG_CMD,ppData,DataNum);
    send_data(h,Buf,BufSize);
    receive_data(h,Buf,&BufSize);
    int cmd = -1;
    parse_ctl_data(Buf,BufSize,&cmd,&DataNum,ppData);
    cluster_t *cluster = init_cluster();
    add_cluster_nodes(cluster, ppData, DataNum);
    close_remote_service(h);
    return cluster;
}
开发者ID:mrmign,项目名称:armingDB,代码行数:34,代码来源:serverNode.c


示例8: receive_data

 connection receive_data(config&           cfg,
                         connection        connection_num,
                         bandwidth_in_ptr* bandwidth_in) // TODO: use this pointer
 {
     // <- just call the previous version without timeouts
     return receive_data(cfg,connection_num, static_cast<unsigned>(0), bandwidth_in);
 }
开发者ID:blackberry,项目名称:Wesnoth,代码行数:7,代码来源:network_ana.cpp


示例9: my_printf

int my_printf(const char *fmt, ...) {
	va_list args;
	char str[256];
	va_start(args, fmt);
	vsprintf(str, fmt, args);
	va_end(args);

	/* setup header and body */
	int header = PRINTF << 24;
	header |= (strlen(str) + 1); /* make sure padded with \0 */

	buff_size = 4 + strlen(str) + 1;
	buff = (char *)calloc(buff_size, 1);
	*(int *)(&buff[0]) = ENDIAN_FLIP(header);
	int u;
	for(u=0;u<strlen(str);u++) {
		buff[4 + u] = str[u];
	}

	/* send data */
	send_data((void *)buff, buff_size, 1);
	/* receive data */
	int len;
	char *pack = receive_data(&len, 0);
	int _ret = (int)*(int *)pack;
	free(pack);
	free(buff);
	return ENDIAN_FLIP(_ret);
}
开发者ID:davestevens,项目名称:Microblaze-FileIO,代码行数:29,代码来源:stdio.c


示例10: my_fread

size_t my_fread(void *ptr, size_t size, size_t nitems, FILE *stream) {
	int header = FREAD << 24;
	header |= 12;

	buff_size = 16;
	buff = (char *)calloc(buff_size, 1);
	*(int *)(&buff[0]) = ENDIAN_FLIP(header);
	*(int *)(&buff[4]) = ENDIAN_FLIP((int)size);
	*(int *)(&buff[8]) = ENDIAN_FLIP((int)nitems);
	*(int *)(&buff[12]) = ENDIAN_FLIP((int)stream);

	/* send data */
	send_data((void *)buff, buff_size, 1);
	/* receive data */
	int len, j;
	char *pack = receive_data(&len, (nitems * size) + 4);

	char *ptrC = (char *)ptr;
	for(j=4;j<len;j++) {
		ptrC[j-4] = pack[j];
	}
	int _ret = (int)*(int *)pack;
	free(pack);
	/* acknowledge the host that packet has been received */
	send_data((void *)(char *)&ret, 4, 1);
	free(buff);
	return ENDIAN_FLIP((int)_ret);
}
开发者ID:davestevens,项目名称:Microblaze-FileIO,代码行数:28,代码来源:stdio.c


示例11: strlen

FILE *my_fopen(const char *filename, const char *mode) {
	int header = FOPEN << 24;
	header |= (strlen(filename) + strlen(mode) + 8);

	buff_size = 12 + strlen(filename) + strlen(mode);
	buff = (char *)calloc(buff_size, 1);
	*(int *)(&buff[0]) = ENDIAN_FLIP(header);
	*(int *)(&buff[4]) = ENDIAN_FLIP(strlen(filename));
	*(int *)(&buff[8]) = ENDIAN_FLIP(strlen(mode));
	int u, v;
	for(u=0;u<strlen(filename);u++) {
		buff[12 + u] = filename[u];
	}
	for(v=0;u<(strlen(filename) + strlen(mode));u++,v++) {
		buff[12 + u] = mode[v];
	}

	/* send data */
	send_data((void *)buff, buff_size, 1);
	/* receive data */
	int len;
	char *pack = receive_data(&len, 0);
	int _ret = (int)*(int *)pack;
	free(pack);
	free(buff);
	_ret = ENDIAN_FLIP(_ret);
	return (FILE *)_ret;
}
开发者ID:davestevens,项目名称:Microblaze-FileIO,代码行数:28,代码来源:stdio.c


示例12: my_fprintf

int my_fprintf(FILE *stream, const char *fmt, ...) {
	va_list args;
	char str[256];
	va_start(args, fmt);
	vsprintf(str, fmt, args);
	va_end(args);

	int header = FPRINTF << 24;
	header |= 4 + strlen(str) + 1;

	buff_size = 8 + strlen(str) + 1;
	buff = (char *)calloc(buff_size, 1);
	*(int *)(&buff[0]) = ENDIAN_FLIP(header);
	*(int *)(&buff[4]) = ENDIAN_FLIP((int)stream);
	int u;
	for(u=0;u<strlen(str);u++) {
		buff[8 + u] = str[u];
	}

	/* send data */
	send_data((void *)buff, buff_size, 1);
	/* receive data */
	int len;
	char *pack = receive_data(&len, 0);
	int _ret = (int)*(int *)pack;
	free(pack);
	free(buff);
	return ENDIAN_FLIP(_ret);
}
开发者ID:davestevens,项目名称:Microblaze-FileIO,代码行数:29,代码来源:stdio.c


示例13: my_fwrite

size_t my_fwrite(const void *ptr, size_t size, size_t nitems, FILE *stream) {
	int header = FWRITE << 24;
	header |= 12 + (size * nitems);

	buff_size = 16 + (size * nitems);
	buff = (char *)calloc(buff_size, 1);
	if(buff == NULL) {
		xil_printf("buff == NULL\n");
		exit(-1);
	}
	*(int *)(&buff[0]) = ENDIAN_FLIP(header);
	*(int *)(&buff[4]) = ENDIAN_FLIP((int)size);
	*(int *)(&buff[8]) = ENDIAN_FLIP((int)nitems);
	*(int *)(&buff[12]) = ENDIAN_FLIP((int)stream);

	int u;
	char *ptrC = (char *)ptr;
	for(u=0;u<(size * nitems);u++) {
		buff[16 + u] = ptrC[u];
	}

	/* send data */
	send_data((void *)buff, buff_size, 1);
	/* receive data */
	int len;
	char *pack = receive_data(&len, 0);
	int _ret = (int)*(int *)pack;
	free(pack);
	free(buff);
	return ENDIAN_FLIP((int)_ret);
}
开发者ID:davestevens,项目名称:Microblaze-FileIO,代码行数:31,代码来源:stdio.c


示例14: Uart_receive

/*==================================================================================================

FUNCTION: Uart_receive

DESCRIPTION:

==================================================================================================*/
uint32 Uart_receive(UartHandle h, char* buf,uint32 bytes_to_rx)
{
   UART_CONTEXT* uart_ctxt;
   uint32 bytes_read;

   UART_LOG_0(INFO,"+Uart_receive");

   if (NULL == h)
   {
      UART_LOG_0(ERROR,"Calling Uart_receive with a NULL handle.");
      return 0;
   }

   if (NULL == buf)
   {
      UART_LOG_0(ERROR,"Calling Uart_receive with a NULL buffer.");
      return 0;
   }

   if (0 == bytes_to_rx)          { return 0; }

   uart_ctxt = (UART_CONTEXT*)h;

   if (FALSE == uart_ctxt->is_port_open)
   {
      UART_LOG_0(ERROR,"Calling Uart_receive on a closed port.");
      return 0;
   }

   bytes_read = receive_data(uart_ctxt,buf,bytes_to_rx);
   UART_LOG_0(INFO,"-Uart_receive");

   return bytes_read;
}
开发者ID:robcore,项目名称:flybirdlaboratory_adsp_proc,代码行数:41,代码来源:Uart.c


示例15: main

int main(void)
{
	uint8_t *val;
	USART_INIT(51);
	USART_SENDSTRING("PROGRAM STARTED");
	initSPI();
	receive_init();
	DDRD |= (1<<LEDPin);		//Set LEDPin as Output
	while(1)
	{
		USART_TRANSMIT(GetReg(CONFIG));
		USART_TRANSMIT(GetReg(STATUS));
		receive_data();
		if(((GetReg(STATUS) & (1<<6)) != 0 ))
		{
			PORTD |= (1<<LEDPin);
			_delay_ms(100);
			PORTD &= ~(1<<LEDPin);
			val = WriteToNrf(R,R_RX_PAYLOAD,val,5);
			for(int i=0;i<5;i++)
			{
				USART_TRANSMIT(val[i]);
			}
		}
		reset();
	}
}
开发者ID:TheAsuraSlayer,项目名称:nRF24L01_AVR,代码行数:27,代码来源:nRF24_RX.c


示例16: main

int main(int argc, char **argv){
    if (argc != 5){
        printf("Wrong args\n");
        exit(0);
    }
    fd = open(argv[4], O_WRONLY|O_CREAT);
    if (fd == -1){
        printf("Error opening log file\n");
        exit(1);
    }
    connected = 0;
    all_get = 0;
    start_seq_num = (unsigned int)rand();
    expected_seq = 0;
    last_seq = 0;
    passive_fin = 0;
    create_sockets();
    ini_send_addr(argv[2]);
    int recv_port = ini_recv_addr();
    conn_server(argv[1], argv[2], argv[3], recv_port);
    printf("Connection established!\n");
    receive_data(argv[1], argv[2], argv[3], recv_port);
    disconnect(argv[1], argv[2], argv[3], recv_port);
    close_sockets();
    close(fd);
    return 0;
}
开发者ID:PredragWang,项目名称:Socket-and-Cryptograpphy,代码行数:27,代码来源:httpget.c


示例17: prcv_dtq

ER
prcv_dtq(ID dtqid, intptr_t *p_data)
{
	DTQCB	*p_dtqcb;
	bool_t	reqdsp;
	ER		ercd;

	LOG_PRCV_DTQ_ENTER(dtqid, p_data);
	CHECK_TSKCTX_UNL();
	CHECK_DTQID(dtqid);
	p_dtqcb = get_dtqcb(dtqid);

	t_lock_cpu();
	if (receive_data(p_dtqcb, p_data, &reqdsp)) {
		if (reqdsp) {
			dispatch();
		}
		ercd = E_OK;
	}
	else {
		ercd = E_TMOUT;
	}
	t_unlock_cpu();

  error_exit:
	LOG_PRCV_DTQ_LEAVE(ercd, *p_data);
	return(ercd);
}
开发者ID:chenyifu,项目名称:asp_tinet_mb,代码行数:28,代码来源:dataqueue.c


示例18: fiber_receiving

void fiber_receiving(void)
{
	struct nano_timer timer;
	uint32_t data[2] = {0, 0};
	struct net_context *ctx;
	int i = 0;

	ctx = get_context(&any_addr, SRC_PORT, &loopback_addr, DEST_PORT);
	if (!ctx) {
		PRINT("%s: Cannot get network context\n", __func__);
		return;
	}

	nano_timer_init(&timer, data);

	while (1) {
		receive_data("listenFiber", ctx);

		if (CONFIG_NET_15_4_LOOPBACK_NUM != 0 &&
					i >= CONFIG_NET_15_4_LOOPBACK_NUM) {
			nano_fiber_timer_stop(&timer);
			return;
		}

		nano_fiber_timer_start(&timer, SLEEPTICKS);
		nano_fiber_timer_test(&timer, TICKS_UNLIMITED);
		i++;
	}
}
开发者ID:32bitmicro,项目名称:zephyr,代码行数:29,代码来源:network.c


示例19: handshake

static int handshake(rdma_ctx_t ctx)
{
    int retval;
    char data[500];
    unsigned long long int vaddr = 0;
    

    // first send mem size
    sprintf(data, "%lu", ctx->rem_mem_size);
    printk(KERN_WARNING "Sending: %s\n", data);
    send_data(ctx, data, strlen(data));

    // receive handshake data from server
    retval = receive_data(ctx, data, 500);
    printk(KERN_WARNING "data received: %s\n", data);
    
    sscanf(data, "%016Lx:%u:%x:%x:%x", &ctx->rem_vaddr, &ctx->rem_rkey, 
           &ctx->rem_qpn, &ctx->rem_psn, &ctx->rem_lid);
    LOG_KERN(LOG_INFO, ("rem_vaddr: %llu rem_rkey:%u rem_qpn:%d rem_psn:%d rem_lid:%d\n", 
           ctx->rem_vaddr, ctx->rem_rkey, ctx->rem_qpn, ctx->rem_psn, ctx->rem_lid));

    sprintf(data, "%016Lx:%u:%x:%x:%x", 
            vaddr, ctx->rkey, ctx->qpn, ctx->psn, ctx->lid);

    // send handshake data to server
    send_data(ctx, data, strlen(data));

    return 0;
}
开发者ID:jcarreira,项目名称:disag-firebox,代码行数:29,代码来源:rdma_library.c


示例20: _metric_control_response_receive

/*
 * _metric_control_response_receive
 *
 * Response a metric control response
 *
 * Returns 0 on success, -1 on error
 */
static int
_metric_control_response_receive(cerebro_t handle, int fd)
{
  char buf[CEREBRO_MAX_PACKET_LEN];
  unsigned int errnum;
  int bytes_read;

  if ((bytes_read = receive_data(fd, 
                                 CEREBRO_METRIC_CONTROL_RESPONSE_LEN,
                                 buf,
                                 CEREBRO_MAX_PACKET_LEN,
                                 CEREBRO_METRIC_CONTROL_PROTOCOL_CLIENT_TIMEOUT_LEN,
                                 &errnum)) < 0)
    {
      handle->errnum = errnum;
      return -1;
    }
               
  if (bytes_read != CEREBRO_METRIC_CONTROL_RESPONSE_LEN)
    {
      handle->errnum = CEREBRO_ERR_PROTOCOL;
      return -1;
    }

  if (_metric_control_response_check(handle, buf, bytes_read) < 0)
    return -1;

  return 0;
}
开发者ID:BenCasses,项目名称:cerebro,代码行数:36,代码来源:cerebro_metric_control.c



注:本文中的receive_data函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ receive_message函数代码示例发布时间:2022-05-30
下一篇:
C++ receive_chars函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap