From f396fc644474caeed5fbb8e1daf262568a069a51 Mon Sep 17 00:00:00 2001 From: Razvan Deaconescu Date: Tue, 19 Oct 2010 14:39:24 +0300 Subject: [PATCH] test-socket-signal: add timing support to client packets --- Utils/test-socket-signal/client.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/Utils/test-socket-signal/client.c b/Utils/test-socket-signal/client.c index fb4302a..6cfe726 100644 --- a/Utils/test-socket-signal/client.c +++ b/Utils/test-socket-signal/client.c @@ -19,13 +19,14 @@ #define DEFAULT_SERVER_HOST "localhost" #define DATA_SIZE 120 -#define PACKET_INDEX_SIZE 8 +#define PACKET_INDEX_SIZE sizeof(unsigned long long) +#define PACKET_TIMESPEC_SIZE sizeof(time_t) #define TIMER_FREQUENCY_SECS 1 #define CLOCKID CLOCK_REALTIME #define SIG SIGRTMIN -static char data[DATA_SIZE+PACKET_INDEX_SIZE]; +static char data[DATA_SIZE + PACKET_INDEX_SIZE + PACKET_TIMESPEC_SIZE]; /* connection socket */ static int connectfd; @@ -46,6 +47,22 @@ static void print_buffer(void) printf("data: %s\n\n", data); } +static void fill_buffer(void) +{ + static unsigned long long index = 0; + char *ptr; + time_t curr_time_secs; + + curr_time_secs = time(NULL); + + ptr = data + DATA_SIZE; + * (unsigned long long *) ptr = index; + ptr += PACKET_INDEX_SIZE; + * (time_t *) ptr = curr_time_secs; + + index++; +} + static ssize_t send_buffer(int sockfd) { return send(sockfd, data, DATA_SIZE, 0); @@ -55,9 +72,9 @@ static void timer_handler(int sig, siginfo_t *si, void *uc) { ssize_t nbytes; + fill_buffer(); nbytes = send_buffer(connectfd); DIE(nbytes < 0, "send_buffer"); - printf("signal delivered\n"); } static void schedule_timer(void) -- 2.20.1