Socket programming: sendto always fails with errno 22 (EINVAL)
问题 I am always getting no bytes sent, with an errno of 22 (EINVAL, Invalid Argument) with this code. The destination_host is set elsewhere and known to be valid, so I really don't see what is going on. MAXMSGSIZE is 1000. No errors, or warnings. I am compiling with -Wall -Werror -pedantic char *data_rec; u_int data_len; int sockfd; uint16_t *ns; struct sockaddr_in address; struct sockaddr *addr; char *ip; int i; int errno; int bytes_sent; data_len = MAXMSGSIZE; data_rec = malloc(sizeof(char)