when i use sento (UDP) in my program trying to send a mesg from one computer to the same one i get this error
sendto: Can't assign requested address
i tried 127.0.0.1 and the actual IP address but both give the same error
here is the code were i set the addr and use sendto
Code:
tempaddr.sin_family = AF_INET;
tempaddr.sin_port = htons(0);
tempaddr.sin_addr.s_addr = inet_addr("127.0.0.1");
memset(&(tempaddr.sin_zero), '\0', 8);
if((sent = sendto(localsock, argv[2], MAXMSGSIZE-1, 0, (struct sockaddr *)&tempaddr, sin_size)) == -1)
{
perror("sendto");
return -1;
}
anyone know how to solve this problem? or what im doing wrong