24 | | int main(int argc, char *argv[]) { |
25 | | struct Handle handle; |
26 | | //Choosing GUIDs 1 and 2 as reference |
27 | | int mine = 1, other = 2, sent = 0, received = 0, size = 65*1024; |
28 | | |
29 | | //Buffer to send and receive messages; I don't care about the content |
30 | | u_char buf[size]; |
31 | | |
32 | | //Requesting basic transport. Listening for GUID mine |
33 | | ret = mfopen(&handle, "basic\0", NULL, mine); |
34 | | if(ret) { |
35 | | fprintf(stderr, "receiver: mfopen error\n"); |
36 | | return (EXIT_FAILURE); |
37 | | } |
38 | | |
39 | | //Send message to other. No additional services requested |
40 | | sent = mfsend(&handle, buf, size, other, NULL); |
41 | | if (sent < 0) { |
42 | | fprintf (stderr,"mfsendmsg error\n"); |
43 | | return EXIT_FAILURE; |
44 | | } |
45 | | |
46 | | //Wait to receive new message |
47 | | received = mfrecv_blk(&handle, buf, size, NULL, 0); |
48 | | if (received < 0) { |
49 | | fprintf (stderr,"mfrecv_blk error\n"); |
50 | | return EXIT_FAILURE; |
51 | | } |
52 | | |
53 | | printf("Intended to send %d bytes, sent %d bytes, received %d bytes\n", size, sent, received); |
| 24 | int main(int argc, char *argv[]) { |
| 25 | struct Handle handle; |
| 26 | //Choosing GUIDs 1 and 2 as reference |
| 27 | int mine = 1, other = 2, sent = 0, received = 0, size = 65*1024; |
55 | | mfclose(&handle); |
56 | | return EXIT_SUCCESS; |
57 | | } |
| 29 | //Buffer to send and receive messages; I don't care about the content |
| 30 | u_char buf[size]; |
| 31 | |
| 32 | //Requesting basic transport. Listening for GUID mine |
| 33 | ret = mfopen(&handle, "basic\0", NULL, mine); |
| 34 | if(ret) { |
| 35 | fprintf(stderr, "receiver: mfopen error\n"); |
| 36 | return (EXIT_FAILURE); |
| 37 | } |
| 38 | |
| 39 | //Send message to other. No additional services requested |
| 40 | sent = mfsend(&handle, buf, size, other, NULL); |
| 41 | if (sent < 0) { |
| 42 | fprintf (stderr,"mfsendmsg error\n"); |
| 43 | return EXIT_FAILURE; |
| 44 | } |
| 45 | |
| 46 | //Wait to receive new message |
| 47 | received = mfrecv_blk(&handle, buf, size, NULL, 0); |
| 48 | if (received < 0) { |
| 49 | fprintf (stderr,"mfrecv_blk error\n"); |
| 50 | return EXIT_FAILURE; |
| 51 | } |
| 52 | |
| 53 | printf("Intended to send %d bytes, sent %d bytes, received %d bytes\n", size, sent, received); |
| 54 | |
| 55 | mfclose(&handle); |
| 56 | return EXIT_SUCCESS; |
| 57 | } |