2 #include <stdlib.h> /* atoi */
3 #include <unistd.h> /* sleep */
5 #include <string.h> /* memset */
7 #include "frsh.h" // for FRSH_CPU_ID_DEFAULT
9 #include "fna.h" // for fna_vres_id_t
10 #include "unix_fna.h" // for unix_fna_operations
12 #define THE_SENDER_ADDR 0
13 #define THE_RECEIVER_ADDR 1
14 #define THE_STREAM_ID 3
22 err = unix_fna_operations.fna_init(FRSH_NETWORK_ID_DEFAULT);
25 printf("I am %d\n", FRSH_CPU_ID_DEFAULT);
27 switch(FRSH_CPU_ID_DEFAULT) {
35 printf("wrong node number\n");
45 frsh_contract_t contract;
46 fna_endpoint_data_t endpoint;
50 printf("I am the sender\n");
52 err = unix_fna_operations.fna_contract_negotiate
53 (FRSH_NETWORK_ID_DEFAULT,
58 endpoint.endpoint_type = FRSH_SEND_ENDPOINT_TYPE;
59 endpoint.is_bound = true;
60 endpoint.destination = THE_RECEIVER_ADDR;
61 endpoint.resource_id = FRSH_NETWORK_ID_DEFAULT;
62 endpoint.stream_id = THE_STREAM_ID;
66 size = snprintf(buffer, sizeof(buffer), "hello world %d", i);
68 err = unix_fna_operations.fna_send_async(&endpoint,
73 printf("sender : sent %s\n", buffer);
76 printf("Sender done\n");
82 fna_endpoint_data_t endpoint;
83 frsh_network_address_t from;
85 size_t received_bytes;
87 printf("I am the receiver\n");
89 endpoint.endpoint_type = FRSH_RECEIVE_ENDPOINT_TYPE;
90 endpoint.is_bound = false;
91 endpoint.resource_id = FRSH_NETWORK_ID_DEFAULT;
92 endpoint.stream_id = THE_STREAM_ID;
94 err = unix_fna_operations.fna_receive_endpoint_created(&endpoint);
98 err = unix_fna_operations.fna_receive_sync(&endpoint,
105 buffer[received_bytes] = '\0';
107 printf("receiver : received %s from %d\n", buffer, from);
110 printf("Receiver done\n");