]> rtime.felk.cvut.cz Git - frescor/frsh-forb.git/commitdiff
fwp: added port argument to demo_receiver
authorTuka Martin <tukamart@fel.cvut.cz>
Sun, 6 May 2012 18:35:05 +0000 (20:35 +0200)
committerTuka Martin <tukamart@fel.cvut.cz>
Sun, 6 May 2012 18:35:05 +0000 (20:35 +0200)
src/fwp/fwp/demo/receiver_fwp_declarations.c

index e92a854cbb104f8f71f4c98f041b66004cf433f8..7a603ee9eaec034b464dc9b1ec957ad057663879 100644 (file)
@@ -27,8 +27,9 @@
 #include "fwp_confdefs.h"
 #include "fwp.h"
 
-int main()
+int main(int argc, char* argv[])
 {
+       int opt;
        ssize_t len;
        char buffer[1000000];
        struct fwp_endpoint *repoint1;
@@ -37,24 +38,38 @@ int main()
        bool opt_daemon = false;
        fwp_endpoint_attr_init(&attr);
        opt_daemon = true;
+       int stream_id = 7777;
+       int count = 0;
        printf("Start\n");
+
+       while ((opt = getopt (argc, argv, "e:p:m:")) != -1) {
+               switch (opt) {
+                       case 'p':
+                               stream_id = atoi(optarg);
+                               break;
+                       case '?':
+                               printf("Usage: %s -p stream_id\n", 
+                                               argv[0]); 
+               }
+       }
        
        if (fwp_init() != 0) {
                printf("FWP initialization failed!\n");
                return -1;
        }
-       if (fwp_receive_endpoint_create(7777, &attr,&repoint1) < 0){
+       if (fwp_receive_endpoint_create(stream_id, &attr,&repoint1) < 0){
                return -1;
        }
        printf("Receive endpoint created\n");
        
        while(1) {
+               count++;
                if ((len = fwp_recv(repoint1, buffer, sizeof(buffer), &from, 
                        0)) < 0) {
                        perror("Error while receiving data");
                        return -1;
                } 
-               else printf("Received - %d\n", len);//buffer);
+               else printf("%d received - %d\n", count, len);//buffer);
        }
        return 0;
 }