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

C++ recv_msg函数代码示例

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

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



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

示例1: Poisson_comm

/* See ML Guide.                                                        */
int Poisson_comm(double x[], void *A_data)
{
   int    proc, neighbor, length, *itemp;
   double send_buffer[2], recv_buffer[2];
   MPI_Request request;

   itemp = (int *) A_data;
   proc  = *itemp; 

   length = 2;
   if (proc == 0) {
      neighbor = 1;
      send_buffer[0] = x[0]; send_buffer[1] = x[1];
      post_msg((char *) recv_buffer,  length, neighbor, &request);
      send_msg((char *) send_buffer,  length, neighbor);
      recv_msg((char *) recv_buffer,  length, neighbor, &request);
      x[2] = recv_buffer[1]; x[3] = recv_buffer[0];
   }
   else {
      neighbor = 0;
      send_buffer[0] = x[0]; send_buffer[1] = x[2];
      post_msg((char *) recv_buffer,  length, neighbor, &request);
      send_msg((char *) send_buffer,  length, neighbor);
      recv_msg((char *) recv_buffer,  length, neighbor, &request);
      x[3] = recv_buffer[1]; x[4] = recv_buffer[0];
   }
   return 0;
}
开发者ID:haripandey,项目名称:trilinos,代码行数:29,代码来源:mlguide_par.c


示例2: exchange_addr_key

static int exchange_addr_key(void)
{
	struct fi_rma_iov *rma_iov;
	int ret;

	rma_iov = buf;

	if (opts.dst_addr) {
		rma_iov->addr = fi->domain_attr->mr_mode == FI_MR_SCALABLE ?
				0 : (uintptr_t) buf;
		rma_iov->key = fi_mr_key(mr);
		ret = send_msg(sizeof *rma_iov);
		if (ret)
			return ret;

		ret = recv_msg();
		if (ret)
			return ret;
		remote = *rma_iov;
	} else {
		ret = recv_msg();
		if (ret)
			return ret;
		remote = *rma_iov;

		rma_iov->addr = fi->domain_attr->mr_mode == FI_MR_SCALABLE ?
				0 : (uintptr_t) buf;
		rma_iov->key = fi_mr_key(mr);
		ret = send_msg(sizeof *rma_iov);
		if (ret)
			return ret;
	}

	return 0;
}
开发者ID:jhrobichaux,项目名称:fabtests-cray,代码行数:35,代码来源:rdm_rma.c


示例3: sync_test

static int sync_test(void)
{
	int ret;

	ret = dst_addr ? send_msg(16) : recv_msg(16);
	if (ret)
		return ret;

	return dst_addr ? recv_msg(16) : send_msg(16);
}
开发者ID:VinGorilla,项目名称:gpunet,代码行数:10,代码来源:riostream.c


示例4: recv_ack

void recv_ack() {
  char  buf[READBUFLEN];
  const char *reply;
  memset(buf, 0, READBUFLEN);
  reply = recv_msg(buf, READBUFLEN);
  while (reply && reply[0] != '.') {
    printf("Unexpected reply: >>%s<<\n", reply);
    reply = recv_msg(buf, READBUFLEN);
  }
}
开发者ID:AliAliyev,项目名称:Robotics-maze-challenge,代码行数:10,代码来源:picomms.c


示例5: sync_test

static int sync_test(void)
{
	int ret;

	ret = opts.dst_addr ? send_msg(16, tag_control) : recv_msg(tag_control);
	if (ret)
		return ret;

	ret = opts.dst_addr ? recv_msg(tag_control) : send_msg(16, tag_control);

	return ret;
}
开发者ID:charlesarcher,项目名称:fabtests,代码行数:12,代码来源:rdm_tagged_search.c


示例6: init_test

int16_t init_test(int32_t sockfd, char *user, char *password,  direction_t direction, uint16_t mtu){
	uint8_t *buffer, challenge[CHALLENGE_SIZE], response[RESPONSE_SIZE];
	int32_t numbytes, rv=0;

	buffer = (uint8_t *) malloc(mtu);

	if (recv_msg(sockfd, buffer, mtu, MSG_OK, &numbytes) != 0){
		close(sockfd);
		free(buffer);
		return RETURN_ERROR;
	}

	switch(direction){
		case RECEIVE:
			rv = send_msg(sockfd, MSG_TCP_DOWN, sizeof(MSG_TCP_DOWN));
			break;
		case SEND:
			rv = send_msg(sockfd, MSG_TCP_UP, sizeof(MSG_TCP_UP));
			break;
		case BOTH:
			rv = send_msg(sockfd, MSG_TCP_BOTH, sizeof(MSG_TCP_BOTH));
			break;
	}
	if (rv != 0){
		close(sockfd);
		free(buffer);
		return RETURN_ERROR;
	}

	rv = recv_msg(sockfd, buffer, mtu, MSG_OK, &numbytes);
	if (rv == RETURN_OK){
		free(buffer);
		return RETURN_OK;
	}
	else if (rv == RETURN_MSG_MISMATCH){
		if (numbytes == CHALLENGE_TOTAL_SIZE && memcmp(buffer, CHALLENGE_HEADER, sizeof(CHALLENGE_HEADER)) == 0){
			memcpy(challenge, buffer+sizeof(CHALLENGE_HEADER), CHALLENGE_SIZE);
			craft_response(user, password, challenge, response);
			if (send_msg(sockfd, response, sizeof(response)) == 0){
				if (recv_msg(sockfd, buffer, mtu, MSG_OK, &numbytes) == 0){
					free(buffer);
					return RETURN_OK;
				}
			}
		}
	}
	fprintf(stderr, "Auth failed\n");
	close(sockfd);
	free(buffer);
	return RETURN_ERROR;
}
开发者ID:kadosch,项目名称:mikrotik_btest,代码行数:51,代码来源:utils.c


示例7: clear_all_signalled

static void clear_all_signalled(CuTest *tc)
{
    apr_status_t rv;
    int srv = SMALL_NUM_SOCKETS;

    recv_msg(s, 0, p, tc);
    recv_msg(s, 2, p, tc);

    rv = apr_poll(pollarray, SMALL_NUM_SOCKETS, &srv, 2 * APR_USEC_PER_SEC);
    CuAssertIntEquals(tc, 1, APR_STATUS_IS_TIMEUP(rv));
    check_sockets(pollarray, s, 0, 0, tc);
    check_sockets(pollarray, s, 1, 0, tc);
    check_sockets(pollarray, s, 2, 0, tc);
}
开发者ID:kheradmand,项目名称:Break,代码行数:14,代码来源:testpoll.c


示例8: clear_middle_pollset

static void clear_middle_pollset(CuTest *tc)
{
    apr_status_t rv;
    int lrv;
    const apr_pollfd_t *descs = NULL;

    recv_msg(s, 2, p, tc);
    recv_msg(s, 5, p, tc);

    rv = apr_pollset_poll(pollset, 0, &lrv, &descs);
    CuAssertIntEquals(tc, 1, APR_STATUS_IS_TIMEUP(rv));
    CuAssertIntEquals(tc, 0, lrv);
    CuAssertPtrEquals(tc, NULL, descs);
}
开发者ID:kheradmand,项目名称:Break,代码行数:14,代码来源:testpoll.c


示例9: clear_all_signalled

static void clear_all_signalled(abts_case *tc, void *data)
{
    apr_status_t rv;
    int srv = SMALL_NUM_SOCKETS;

    recv_msg(s, 0, p, tc);
    recv_msg(s, 2, p, tc);

    rv = apr_poll(pollarray, SMALL_NUM_SOCKETS, &srv, 2 * APR_USEC_PER_SEC);
    ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(rv));
    check_sockets(pollarray, s, 0, 0, tc);
    check_sockets(pollarray, s, 1, 0, tc);
    check_sockets(pollarray, s, 2, 0, tc);
}
开发者ID:Ga-vin,项目名称:apache,代码行数:14,代码来源:testpoll.c


示例10: clear_middle_pollset

static void clear_middle_pollset(abts_case *tc, void *data)
{
    apr_status_t rv;
    int lrv;
    const apr_pollfd_t *descs = NULL;

    recv_msg(s, 2, p, tc);
    recv_msg(s, 5, p, tc);

    rv = apr_pollset_poll(pollset, 0, &lrv, &descs);
    ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(rv));
    ABTS_INT_EQUAL(tc, 0, lrv);
    ABTS_PTR_EQUAL(tc, NULL, descs);
}
开发者ID:Ga-vin,项目名称:apache,代码行数:14,代码来源:testpoll.c


示例11: tcp_get_rep

/* Used internally to get and parse replies from the server. */
uint32_t tcp_get_rep(struct nmdb_srv *srv,
                     unsigned char *buf, size_t bsize,
                     unsigned char **payload, size_t *psize)
{
    ssize_t rv;
    uint32_t id, reply;

    rv = recv_msg(srv->fd, buf, bsize);
    if (rv <= 0)
        return -1;

    id = * ((uint32_t *) buf + 1);
    id = ntohl(id);
    reply = * ((uint32_t *) buf + 2);
    reply = ntohl(reply);

    if (id != ID_CODE) {
        return -1;
    }

    if (payload != NULL) {
        *payload = buf + 4 + 4 + 4;
        *psize = rv - 4 - 4 - 4;
    }
    return reply;
}
开发者ID:dolfly,项目名称:nmdb,代码行数:27,代码来源:tcp.c


示例12: MFS_Stat

//Function 2 Send Format: Function_num,inum
int MFS_Stat(int inum, MFS_Stat_t* m)
{
	memset(com_t.message, 0, MSG_BUFFER_SIZE); //Clear the send buffer
	
	snprintf(com_t.message, 2*sizeof(int), "%d%d", 2, inum); //Function 2 -- MFS_Stat

#ifdef DEBUG
	printf("\n----MFS_Stat Sent message: %s\n", com_t.message);
#endif
	
	if(send_msg() < 0)
		return -1;

	//Once you recieve the response, fill in the MFS_Stat structure
	if(recv_msg() < 0)
	{
		printf("					CLIENT:: Message was not recieved\n");
		return -1;
	}

#ifdef DEBUG
	printf("----MFS_Stat Recieved message: %s\n", com_t.buffer);
#endif 

	return 0;
}
开发者ID:vinaygangadhar,项目名称:cs537_projects,代码行数:27,代码来源:mfs.c


示例13: remote_tcp_do_job

unsigned int remote_tcp_do_job(void *acc_ctx, const char *param, unsigned int job_len, void ** result_buf) {
    //printf("job_len = %d\n", job_len);
	struct timeval t1, t2, dt;
    unsigned long send_sec, recv_sec;
    struct acc_context_t *acc_context = (struct acc_context_t *) acc_ctx;
    struct scheduler_context_t * scheduler_ctx = acc_context->scheduler_context;
    struct tcp_client_context_t *tcp_ctx = (struct tcp_client_context_t *)acc_context->tcp_context;

    double max_bps = scheduler_ctx->max_bps;
    double send_bps, recv_bps;
    unsigned int recv_buf_size;
    *result_buf = tcp_ctx->out_buf;
    char *in_buf = (char *)tcp_ctx->in_buf;
    int fd = tcp_ctx->to_server_fd;

    gettimeofday(&t1, NULL);
    size_t len = send_msg(fd, in_buf, job_len, MTU, max_bps); 
    gettimeofday(&t2, NULL);
    timersub(&t2,&t1,&dt);
    send_sec = dt.tv_usec + 1000000* dt.tv_sec;
    send_bps = ((double)job_len*1000000)/send_sec;


    int tmp_size = 16;
    recv_buf_size = recv_msg(fd, *result_buf, tmp_size, MTU, max_bps);
    recv_buf_size = job_len;

    printf("Transfer Rate: %.2f KB/s\n", send_bps/1024);
    return recv_buf_size; 
} 
开发者ID:zhuangdizhu,项目名称:testAPI,代码行数:30,代码来源:tcp_transfer.c


示例14: while

 void GenericCommunicator::RecvThread::runRecvEventLoopClients()
 {
     // Host expects one termination request from each client.
     // Clients expect two termination requests from the host.
     int nTerminationRequestsExpected = 2;
     int nTerminationRequests = 0;
     bool done = false;
     do {
         int sender;
         if( ! recv_msg( sender ) ) {
             // normal message
         } else {
             // wasTerminationRequest
             CNC_ASSERT( sender == 0 ); // termination request from host
             ++nTerminationRequests;
             if ( nTerminationRequests == 1 ) {
                 m_instance.send_termination_request( 0 ); // send back to the host
             }
             if ( nTerminationRequests == nTerminationRequestsExpected ) {
                 done = true;
             }
             // For the rest of this run, the clients can only communicate
             // with the host. Disable all other client connections !!!
             m_channel.invalidate_client_communication_channels();
         }
     } while ( ! done );
 }
开发者ID:jbrodman,项目名称:icnc,代码行数:27,代码来源:GenericCommunicator.cpp


示例15: timeout_pollin_pollcb

static void timeout_pollin_pollcb(abts_case *tc, void *data)
{
    apr_status_t rv;
    pollcb_baton_t pcb;
    apr_pollfd_t socket_pollfd;

    POLLCB_PREREQ;

    recv_msg(s, 0, p, tc);
    
    ABTS_PTR_NOTNULL(tc, s[0]);
    socket_pollfd.desc_type = APR_POLL_SOCKET;
    socket_pollfd.reqevents = APR_POLLIN;
    socket_pollfd.desc.s = s[0];
    socket_pollfd.client_data = s[0];
    rv = apr_pollcb_add(pollcb, &socket_pollfd);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
    
    pcb.count = 0;
    pcb.tc = tc;
    
    rv = apr_pollcb_poll(pollcb, 1, trigger_pollcb_cb, &pcb);    
    ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(rv));
    ABTS_INT_EQUAL(tc, 0, pcb.count);

    rv = apr_pollcb_remove(pollcb, &socket_pollfd);
    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
}
开发者ID:Ga-vin,项目名称:apache,代码行数:28,代码来源:testpoll.c


示例16: MFS_Write

//Function 3 Send Format: Function_num,inum,No_of_char_bytes,char_bytes,block
int MFS_Write(int inum, char* buffer, int block)
{
	memset(com_t.message, 0, MSG_BUFFER_SIZE); //Clear the send buffer

	int len = strlen(buffer);

	//Packing the block first before the write content
	snprintf(com_t.message, 4*sizeof(int), "%d%d%04d%d", 3, inum, len, block); //Function 3 -- MFS_Write
	strcat(com_t.message, buffer);

#ifdef DEBUG
	printf("\n----MFS_Write Sent message: %s\n", com_t.message);
#endif
	
	if(send_msg() < 0)
		return -1;

	//Once you recieve the response, response is write success or failure
	if(recv_msg() < 0)
	{
		printf("					CLIENT:: Message was not recieved\n");
		return -1;
	}

#ifdef DEBUG
	printf("----MFS_Write Recieved message: %s\n", com_t.buffer);
#endif 
	
	return 0;
}
开发者ID:vinaygangadhar,项目名称:cs537_projects,代码行数:31,代码来源:mfs.c


示例17: play

void play(){
  if(dnum > 21){
    send_msg("win", client_sock);
    return;
  }
  
  if(pnum > 21){
    send_msg("lose", client_sock);
    return;
  }
  
  send_msg("inp", client_sock);
  int i = 0;
  while(recv_msg(buf, 256, client_sock) != 0){
    if(!strncmp("hit", buf, 3)){
      player[pnumcards] = top();
      pnum += player[pnumcards]->value;
      pnumcards++;
      send_msg("msg", client_sock);
      sprintf(String, "Player:");
      for(i = 0; i < pnumcards; i++){
        strcat(String, " ");
        strcat(String, player[i]->rep);
      }
      strcat(String, "\n");
      send_msg(String, client_sock);
      if(pnum > 21){
        send_msg("lose", client_sock);
        return;
      }else{
        send_msg("inp", client_sock);
      }
    }else{
      while(dnum < 17){
        dealer[dnumcards] = top();
        dnum += dealer[dnumcards]->value;
        dnumcards++;
        send_msg("msg", client_sock);
        sprintf(String, "Dealer:");
        for(i = 0; i < dnumcards; i++){
          strcat(String, " ");
          strcat(String, dealer[i]->rep);
        }
        strcat(String, "\n");
        send_msg(String, client_sock);
      }
      
      if(dnum > pnum){
        send_msg("lose", client_sock);
        return;
      }else if(dnum < pnum){
        send_msg("win", client_sock);
        return;
      }else{
        send_msg("tie", client_sock);
        return;
      }
    }
  }
}
开发者ID:clholgat,项目名称:CSC246,代码行数:60,代码来源:server.c


示例18: main

int main()
{
    int msg_id = create_msg_queue();

    char buf[_SIZE_];
    while(1)
    {
	memset(buf,'\0',sizeof(buf));

	sleep(20);

	recv_msg(msg_id,_CLIENT_TYPE_,buf);

	printf("client -> server:%s\n",buf);

	printf("请输入:");
	fflush(stdout);

	read(0,buf,sizeof(buf)-1);
	send_msg(msg_id,_SERVER_TYPE_,buf);
    }

    destroy_msg_queue(msg_id);
    return 0;
}
开发者ID:LI8023NING,项目名称:Linux-Network,代码行数:25,代码来源:client.c


示例19: pause

/*
 * int pause();
 * 使自身进程处于挂起状态
 *其他进程向其发送信号将使它激活
 *
 * 成功返回信号类型。失败返回-1
 */
int pause(){
	MSG *p_msg;
	int signal = -1;

	p_msg = get_msg();

	p_msg->type = MSG_PAUSE;



	send_msg(p_msg);


	/*
	 * 这里使借鉴了wait(signal)的设计。因为发送包到处理会有一段时间,因此调用程序完全可能跨越pause()而执行之后的部分程序
	 * 这是不被允许的。因此使用此循环,因为pause()的进程被激活是有进程向其发送包,所以其接收队列中一定有信号包。
	 */


	while(1){
		p_msg = recv_msg();

		if(p_msg -> type == MSG_SIGNAL){
			signal = p_msg->signal;
			del_msg(p_msg);
			return signal;	//返回信号的类型
		}

		if(p_msg != (MSG *)NULL)
			reload_msg(p_msg);	//如果出现了自己不需要的消息,将会把该消息重新放入自己的收件箱

	}	//end while


}
开发者ID:nmsoccer,项目名称:micro_kernel,代码行数:42,代码来源:unistd.c


示例20: recv_msg

bool
UDPsocket::recv_msg( char * buf,
                     int & len,
                     bool redirect )
{
    return recv_msg( buf, len, MAXMESG, redirect );
}
开发者ID:gunuer,项目名称:robocup-defence-darkterror,代码行数:7,代码来源:udpsocket.C



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ recv_skip函数代码示例发布时间:2022-05-30
下一篇:
C++ recv_line函数代码示例发布时间: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