[Aggregator] Improve UDP socket-related code
This commit is contained in:
parent
c567592167
commit
52106177a1
|
@ -860,6 +860,13 @@ void* monitor_requests(void *const NULL_value)
|
||||||
if (VERBOSE_WARNING)
|
if (VERBOSE_WARNING)
|
||||||
fprintf(stderr, "Monitor requests thread launched.\n") ;
|
fprintf(stderr, "Monitor requests thread launched.\n") ;
|
||||||
|
|
||||||
|
/* Open the socket to the positioning server
|
||||||
|
* We don't need to check wether or not the socket was opened
|
||||||
|
* successfuly because the network transmission is not mandatory
|
||||||
|
* (aggregated data will be written to the output file
|
||||||
|
* anyway). owl_close_fd() and the rest of the code here handle
|
||||||
|
* negative file descriptors.
|
||||||
|
*/
|
||||||
sockfd =
|
sockfd =
|
||||||
owl_create_udp_trx_socket(cfg_getstr(cfg, "positioner_host"),
|
owl_create_udp_trx_socket(cfg_getstr(cfg, "positioner_host"),
|
||||||
cfg_getint(cfg, "positioner_port"),
|
cfg_getint(cfg, "positioner_port"),
|
||||||
|
@ -1020,7 +1027,8 @@ void flush_request_list(FILE *const stream,
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* - request_ptr: the request to print
|
* - request_ptr: the request to print
|
||||||
* - stream: the stream to print to
|
* - stream: the stream to print to
|
||||||
* - sockfd: the file descriptor of the socket to send to
|
* - sockfd: the file descriptor of the socket to send to (can be
|
||||||
|
* negative, in which case no transmission will be attempted)
|
||||||
* - serv: the server's information
|
* - serv: the server's information
|
||||||
*/
|
*/
|
||||||
void output_request(request_list *const request_ptr,
|
void output_request(request_list *const request_ptr,
|
||||||
|
@ -1082,7 +1090,13 @@ void output_request(request_list *const request_ptr,
|
||||||
}
|
}
|
||||||
request.nb_info = htons(request.nb_info) ;
|
request.nb_info = htons(request.nb_info) ;
|
||||||
// Send the request's main data:
|
// Send the request's main data:
|
||||||
sendto(sockfd, &request, sizeof(request), 0, serv, serv_len) ;
|
if (sockfd >= 0)
|
||||||
|
{
|
||||||
|
ssize_t n;
|
||||||
|
n = sendto(sockfd, &request, sizeof(request), 0, serv, serv_len);
|
||||||
|
if (n != sizeof(request))
|
||||||
|
perror("Couldn't send the request's main data");
|
||||||
|
}
|
||||||
|
|
||||||
// Send request's per-CP information to the server and delete it
|
// Send request's per-CP information to the server and delete it
|
||||||
// from the request
|
// from the request
|
||||||
|
@ -1096,7 +1110,13 @@ void output_request(request_list *const request_ptr,
|
||||||
info.capture_time = request_info_ptr->capture_time ;
|
info.capture_time = request_info_ptr->capture_time ;
|
||||||
owl_hton_timestamp(&info.capture_time) ;
|
owl_hton_timestamp(&info.capture_time) ;
|
||||||
info.ss_dbm = request_info_ptr->ss_dbm ;
|
info.ss_dbm = request_info_ptr->ss_dbm ;
|
||||||
sendto(sockfd, &info, sizeof(info), 0, serv, serv_len) ;
|
if (sockfd >= 0)
|
||||||
|
{
|
||||||
|
ssize_t n;
|
||||||
|
n = sendto(sockfd, &info, sizeof(info), 0, serv, serv_len);
|
||||||
|
if (n != sizeof(info))
|
||||||
|
perror("Couldn't send the CP information");
|
||||||
|
}
|
||||||
|
|
||||||
// Print CP info to the output file
|
// Print CP info to the output file
|
||||||
owl_mac_bytes_to_string_r(request_info_ptr->cp_mac_addr_bytes,
|
owl_mac_bytes_to_string_r(request_info_ptr->cp_mac_addr_bytes,
|
||||||
|
@ -1497,6 +1517,11 @@ void order_send(const cp_list *const cp)
|
||||||
cfg_getint(cfg,
|
cfg_getint(cfg,
|
||||||
"autocalibration_order_port"),
|
"autocalibration_order_port"),
|
||||||
&serv) ;
|
&serv) ;
|
||||||
|
if (sockfd < 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Can't transmit autocalibration order.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
message.order = AUTOCALIBRATION_ORDER_SEND ;
|
message.order = AUTOCALIBRATION_ORDER_SEND ;
|
||||||
nsent = sendto(sockfd, &message, sizeof(message), 0, &serv, serv_len) ;
|
nsent = sendto(sockfd, &message, sizeof(message), 0, &serv, serv_len) ;
|
||||||
|
|
Loading…
Reference in New Issue