/* * This is a simple program to demonstrate the use of * libowlps-resultreader-udp. * It must be linked against libowlps and its dependencies * (see the Makefile). */ #include "owlps-resultreader-udp.h" #include #include int main(void) { struct sigaction action ; // Signal handler structure owl_result *result ; int sockfd ; /* Set up signal handlers */ action.sa_flags = 0 ; sigemptyset(&action.sa_mask) ; action.sa_handler = owl_sigint_handler ; sigaction(SIGINT, &action, NULL) ; action.sa_handler = owl_sigterm_handler ; sigaction(SIGTERM, &action, NULL) ; /* Open the socket */ sockfd = owl_create_udp_listening_socket(OWL_DEFAULT_RESULT_PORT) ; if (sockfd < 0) return 1 ; /* Read loop */ owl_run = owl_true ; while (owl_run) { if (! (result = owl_receive_position(sockfd))) return 1 ; owl_print_result(result) ; owl_free_result(result) ; printf("--------------\n") ; } /* Cleaning */ close(sockfd) ; return 0 ; }