From 1ef6ae06d757f19691d996b4d7d37997997ba775 Mon Sep 17 00:00:00 2001 From: Tuka Martin Date: Sun, 6 May 2012 20:35:05 +0200 Subject: [PATCH] fwp: added port argument to demo_receiver --- src/fwp/fwp/demo/receiver_fwp_declarations.c | 21 +++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/fwp/fwp/demo/receiver_fwp_declarations.c b/src/fwp/fwp/demo/receiver_fwp_declarations.c index e92a854c..7a603ee9 100644 --- a/src/fwp/fwp/demo/receiver_fwp_declarations.c +++ b/src/fwp/fwp/demo/receiver_fwp_declarations.c @@ -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; } -- 2.39.2