NewMadeleine

Documentation

« back to PM2 home.
nm_sr_hello.c
/*
* NewMadeleine
* Copyright (C) 2006-2023 (see AUTHORS file)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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.
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include "../common/nm_examples_helper.h"
const char *msg = "hello, world";
int main(int argc, char**argv)
{
uint64_t len = 1 + strlen(msg);
char*buf = malloc((size_t)len);
{
/* server side */
nm_sr_request_t request;
memset(buf, 0, len);
nm_sr_irecv(p_session, NM_ANY_GATE, 0, buf, len, &request);
nm_sr_rwait(p_session, &request);
printf("buffer contents: %s\n", buf);
}
else
{
/* client side */
nm_sr_request_t request;
strcpy(buf, msg);
nm_sr_isend(p_session, p_gate, 0, buf, len, &request);
nm_sr_swait(p_session, &request);
}
free(buf);
exit(0);
}
static int is_server
@ NM_EXAMPLES_TOPO_PAIRS
static nm_session_t p_session
static void nm_examples_exit(void)
static void nm_examples_init_topo(int *argc, char *argv[], enum nm_example_topo_e topo)
static nm_gate_t p_gate
uint16_t len
chunk len
Definition nm_headers.h:0
static int nm_sr_swait(nm_session_t p_session, nm_sr_request_t *p_request)
Wait for the completion of a non blocking send request.
static int nm_sr_rwait(nm_session_t p_session, nm_sr_request_t *p_request)
Wait for the completion of a non blocking receive request.
static int nm_sr_irecv(nm_session_t p_session, nm_gate_t p_gate, nm_tag_t tag, void *data, nm_len_t len, nm_sr_request_t *p_request)
Post a non blocking receive request.
static int nm_sr_isend(nm_session_t p_session, nm_gate_t p_gate, nm_tag_t tag, const void *data, nm_len_t len, nm_sr_request_t *p_request)
Post a non blocking send request.
#define NM_ANY_GATE
Definition nm_types.h:41
internal defintion of the sendrecv request