From: Razvan Deaconescu Date: Tue, 19 Oct 2010 11:59:58 +0000 (+0300) Subject: test-socket-signal: close server when no more data X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=1b1bd4f50fe1a893707cc028f0635479480866d2;p=p2p-testing-infrastructure.git test-socket-signal: close server when no more data --- diff --git a/Utils/test-socket-signal/server.c b/Utils/test-socket-signal/server.c index b2cd28f..a4b0028 100644 --- a/Utils/test-socket-signal/server.c +++ b/Utils/test-socket-signal/server.c @@ -61,15 +61,6 @@ static void print_buffer_meta(void) curr_time_secs - sender_time_secs); } -static void handle_data(int sockfd) -{ - ssize_t nbytes; - - nbytes = receive_buffer(sockfd); - DIE(nbytes < 0, "receive_buffer"); - print_buffer_meta(); -} - int main(void) { int listenfd; @@ -85,7 +76,14 @@ int main(void) DIE(sockfd < 0, "accept"); while (1) { - handle_data(sockfd); + ssize_t nbytes; + + nbytes = receive_buffer(sockfd); + DIE(nbytes < 0, "receive_buffer"); + if (nbytes == 0) + break; + + print_buffer_meta(); } close(sockfd);