#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()
{
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;
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)) {
}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");
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;
}
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;
}