|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Senior Member
Iscritto dal: Aug 2002
Messaggi: 2518
|
[C] gethostbyaddr()
Salve a tutti,
la gethostbyname() sono riuscita ad utilizzarla proprio grazie ad un esempio trovato qui sul forum, ovvero: Codice:
//PROVO LA GETHOSTBYBNAME struct hostent *h = gethostbyname("localhost"); memcpy((char *)&echoServAddr.sin_addr, (char *)h->h_addr_list[0], 4); Codice:
unsigned long ip = inet_addr("127.0.0.1"); struct hostent *host = gethostbyaddr((char *)&ip,4,0); memcpy((char *)&echoServAddr.sin_addr, (char *)host->h_addr_list[0], 4); So che cosi sarebbe solo un giro inutile dire ho l'ip, riempimi la struttura e poi ridammi l'ip, però volevo vedere se funzionava. Oppure se faccio il gethostbyaddr() non mi viene avvalorato l'address list e per questo mi va in segmentation fault? Se potesse servire come informazione sto sotto MacOs e come ide sto con eclipse per c. Vi ringrazio in anticipo, guylmaster. |
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 13:36.