![]() |
| | #1 |
| Registered User Join Date: Oct 2001
Posts: 224
| error using sendto 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;
}
Last edited by c++.prog.newbie; 03-16-2006 at 03:59 PM. |
| c++.prog.newbie is offline | |
| | #2 |
| Registered User Join Date: Oct 2001
Posts: 224
| actually i got a different problem, how do i get the address from a hostent* (h->h_addr) into a myaddr.sin_addr.s_addr ? |
| c++.prog.newbie is offline | |
| | #3 |
| Registered User Join Date: Oct 2001
Posts: 224
| ok i got that problem figured out, im still getting the error sendto: Invalid argument which is printed out using perror("sendto")... i tried entering the following code for debugging purposes Code: cout<<"h_addr_list[0] is: "<<h->h_addr_list[0]<<endl; // same as h_addr cout<<"h_name is: "<<h->h_name<<endl; cout<<"h_aliases[0] is: "<<h->h_aliases[0]<<endl; cout<<"h_addrtype is: "<<h->h_addrtype<<endl; cout<<"h_length is: "<<h->h_length<<endl; if i comment out the aliases line i get the following output Code: [adam@d198-53-226-104 ~]$ ./cs d198-53-226-104.abhsia.telus.net help h_addr_list[0] is: \uffff5 h_name is: d198-53-226-104.abhsia.telus.net h_addrtype is: 2 h_length is: 4 addr is: 198.53.226.104 sendto: Invalid argument any idea how to solve this?? i would appreciate any help Last edited by c++.prog.newbie; 03-20-2006 at 02:19 AM. |
| c++.prog.newbie is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| sendto: Invalid argument netbsd | quantt | C Programming | 5 | 02-15-2009 08:55 PM |
| Error in sending/receiving strings while using sendto() and recvfrom() | ferenczi | Networking/Device Communication | 3 | 11-28-2008 12:12 AM |
| Raw socket and sendto() | matB | Networking/Device Communication | 4 | 07-10-2008 05:07 PM |
| sendto Socket packet size | bj00 | Networking/Device Communication | 0 | 07-27-2007 11:05 AM |
| Socket Datagram info sendto(), recvfrom() | siluro | C Programming | 1 | 02-20-2005 12:10 PM |