add error when sendto fails

This commit is contained in:
2025-05-25 15:27:08 +02:00
parent 64ac4ba5e0
commit cc3cfa3d03
3 changed files with 11 additions and 2 deletions

View File

@ -67,11 +67,18 @@ t_waitlist *send_icmp(t_settings *set, struct addrinfo *host, uint16_t *seq, str
{
t_icmp_echo packet;
t_waitlist *ret;
size_t len;
if(timediff(last) < set->interval)
return (0);
packet = prepare_icmp_echo(*seq, set->id);
sendto(set->socket, &packet, sizeof(t_icmp_echo), 0, host->ai_addr, host->ai_addrlen);
len = sendto(set->socket, &packet, sizeof(t_icmp_echo), 0, host->ai_addr, host->ai_addrlen);
if(len == (size_t)-1)
{
perror(set->name);
set->err = 1;
g_stop = 1;
}
gettimeofday(last, 0);
ret = malloc(sizeof(t_waitlist));
if(!ret)