]> rtime.felk.cvut.cz Git - frescor/fwp.git/blobdiff - fwp/tests/fwp_mngrtest/fwp_mngrtest.c
WIP:bug tracking
[frescor/fwp.git] / fwp / tests / fwp_mngrtest / fwp_mngrtest.c
index 4defa578677237f2ca610728c662d3f56774af83..14a8f0ccb005b6678d5195619b4ae2dde0b1da75 100644 (file)
@@ -6,6 +6,28 @@
 #include <errno.h>
 #include <stdio.h>
 
+fwp_endpoint_attr_t  attr;
+
+void* receiver(void *arg)
+{
+       fwp_endpoint_d_t        repoint_d1;
+       int i,len;
+       char buffer[30];
+
+       if (fwp_receive_endpoint_create(7777, &attr,&repoint_d1) < 0){
+               return ;
+       }
+               
+       FWP_DEBUG("Receive endpoint created \n");
+       for (i = 0; i < 2; i++) {
+               if ((len = fwp_recv(repoint_d1, buffer, sizeof(buffer), 0)) < 0) {
+                       perror("Error while receiving data::");
+                       return ;
+               } 
+                       else printf("Received - %s\n", buffer);
+       }
+}
+
 
 int main()
 {
@@ -15,12 +37,13 @@ int main()
        fwp_endpoint_d_t sepoint_d1, sepoint_d2, repoint_d1, repoint_d2;
        char msg1[] = "Hello1";
        char msg2[] = "Hello2";
-       char buffer[30];
 
        fwp_contract_t cnt1;
        fwp_contract_t cnt2;
        fwp_contract_t cnt3;
 
+       pthread_t       id;
+
        cnt1.budget = 100;
        cnt1.period_usec = 10000;
 
@@ -36,10 +59,12 @@ int main()
                return -1;
        }       
        
-       if (fwp_receive_endpoint_create(7777, 0,&repoint_d1) < 0){
-               return -1;
-       }
-
+       fwp_endpoint_attr_init(&attr);
+       attr.reliability = FWP_EPOINT_RELIABLE;
+       
+       pthread_create(&id, NULL, 
+                           receiver, (void*) NULL);
+       
        cnt1d = fwp_contract_create(&cnt1);
        fwp_contract_negotiate(cnt1d, &vres_d1);
        if (fwp_contract_is_negotiated(cnt1d)) {
@@ -47,7 +72,7 @@ int main()
        }else 
                printf("Contract1 not negotiated.\n");
 
-       cnt2d = fwp_contract_create(&cnt2);
+/*     cnt2d = fwp_contract_create(&cnt2);
        fwp_contract_negotiate(cnt2d, &vres_d2);
        if (fwp_contract_is_negotiated(cnt2d)) {
                printf("Contract2 negotiated.\n");
@@ -60,9 +85,9 @@ int main()
                printf("Contract3 negotiated.\n");
        }else 
                printf("Contract3 not negotiated.\n");
-       
+*/     
        if (fwp_send_endpoint_create(inet_addr("127.0.0.1"), 7777, 
-               0, &sepoint_d1)
+               &attr, &sepoint_d1)
                 < 0) {
                return -1;
        }
@@ -74,16 +99,9 @@ int main()
        fwp_send(sepoint_d1, msg2, sizeof(msg2), 0);
        printf("Sent msg 2\n");
 
-       for (i = 0; i < 2; i++) {
-               if ((len = fwp_recv(repoint_d1, buffer, sizeof(buffer), 0)) < 0) {
-                       perror("Error while receiving data::");
-                       return -1;
-               } 
-                       else printf("Received - %s\n", buffer);
-       }
 
        printf("Test PASSED!\n");
 
-//     scanf("Press key%d",&vres_id1); 
+       scanf("Press key");     
        return 0;
 }