2 * \file fwp_sendrecv_test2.c
4 * This a test application that:
5 * - creates vres without negotiation
6 * - creates reliable send endpoint
7 * - cretaes receiver thread and receive endpoint within it
8 * - binds that endpoint to vres
13 #define CONFIGURE_FWP_MNGT 0
14 #include "fwp_confdefs.h"
20 #include <arpa/inet.h>
24 fwp_endpoint_attr_t attr;
26 void* receiver(void* arg)
28 struct fwp_endpoint *repoint1;
33 printf("Creating receive endpoint\n");
34 if (fwp_receive_endpoint_create(7777, &attr,&repoint1) < 0){
35 perror("Error while creating receive endpoint\n");
39 printf("Receive endpoint created \n");
40 for (i = 0; i < MSGN; i++) {
41 if ((len = fwp_recv(repoint1, buffer, sizeof(buffer), &from,
43 perror("Error while receiving data::");
46 printf("Received %s\n",buffer);
47 //for (j = 0 ; j < 10; i++)
48 // printf("%c", buffer[i]);
60 struct fwp_vres_params vparam1, vparam2;
61 char msg1[] = "Hello1";
62 char msg2[] = "Hello2";
63 struct fwp_endpoint *sepoint1;
66 vparam1.ac_id = FWP_AC_VO;
68 vparam1.period.tv_sec = 0;
69 vparam1.period.tv_nsec = 10000;
71 vparam2.ac_id = FWP_AC_BK;
73 vparam2.period.tv_sec = 0;
74 vparam2.period.tv_nsec = 100000;
77 if (fwp_init() != 0) {
78 printf("FWP initialization failed!\n");
82 fwp_endpoint_attr_init(&attr);
83 fwp_endpoint_attr_setreliability(&attr, FWP_EPOINT_RELIABLE);
85 pthread_create(&thread, NULL, &receiver, (void*) NULL);
86 printf("Create vres1, vres2\n");
87 if (fwp_vres_create(&vparam1, &vres1) < 0) {
88 printf("Unable to create vres1\n");
91 printf("Vres1 created \n");
93 if (fwp_send_endpoint_create(inet_addr("127.0.0.1"), 7777, &attr,
97 printf("Send endpoint 1 created\n");
98 fwp_send_endpoint_bind(sepoint1, vres1);
100 fwp_send_sync(sepoint1, msg1, sizeof(msg1));
101 printf("Sent msg1\n");
102 fwp_send_sync(sepoint1, msg2, sizeof(msg2));
103 printf("Sent msg2\n");
105 pthread_join(thread, (void**) NULL);
106 /*if (fwp_vres_destroy(vres1) < 0) {
107 perror("Unable to destroy vres1\n");
110 printf("Vres1 destroyed\n");
112 if (fwp_vres_destroy(vres2) < 0){
113 perror("Unable to destroy vres2\n");
116 printf("Vres2 destroyed\n");
119 printf("Test PASSED!\n");