From 735ab3b61fe2520b7ebb5b5e9f429d1c8a6d6202 Mon Sep 17 00:00:00 2001 From: Razvan Deaconescu Date: Fri, 15 Oct 2010 19:29:41 +0300 Subject: [PATCH] test-socket: add basic timer functions --- Utils/test-socket-signal/client.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/Utils/test-socket-signal/client.c b/Utils/test-socket-signal/client.c index da1b491..9efc4f2 100644 --- a/Utils/test-socket-signal/client.c +++ b/Utils/test-socket-signal/client.c @@ -10,16 +10,20 @@ #include #include #include +#include #include "sock_util.h" #define DEFAULT_SERVER_LISTEN_PORT 43210 #define DEFAULT_SERVER_HOST "localhost" -#define DATA_SIZE 120 +#define DATA_SIZE 120 +#define PACKET_INDEX_SIZE 8 +static char data[DATA_SIZE+PACKET_INDEX_SIZE]; -static char data[DATA_SIZE]; +/* connection socket */ +static int connectfd; static void init_buffer(void) { @@ -42,9 +46,21 @@ static int send_buffer(int sockfd) return send(sockfd, data, DATA_SIZE, 0); } +static void timer_handler(int sig, siginfo_t *si, void *uc) +{ + if (send_buffer(connectfd) < 0) { + perror("send_buffer"); + exit(EXIT_FAILURE); + } +} + +static void schedule_timer(void) +{ +} + int main(void) { - int connectfd; + sigset_t mask; connectfd = tcp_connect_to_server(DEFAULT_SERVER_HOST, DEFAULT_SERVER_LISTEN_PORT); @@ -53,10 +69,11 @@ int main(void) } init_buffer(); - print_buffer(); - if (send_buffer(connectfd) < 0) { - perror("send_buffer"); - exit(EXIT_FAILURE); + schedule_timer(); + + sigemptyset(&mask); + while (1) { + sigsuspend(&mask); } printf("\n--- data sent!\n"); -- 2.20.1