static ssize_t write_server(int sd, const void *buf, size_t len, struct sockaddr_storage *to)
{
  ssize_t nb;
  for (;;) {
    nb = sendto(sd, buf, len, 0, (struct sockaddr*) to, sizeof(to)); --> return -1

When sendto fails, you can check the value of errno to know the reason. For example:

if (-1 == nb) {
   fprintf (stderr, "sendto failed. Reason: '%s'\n", strerror (errno));
   ...
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.