当前位置: 首页>>代码示例>>C++>>正文


C++ recv_msg函数代码示例

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


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


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