Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Didattica > Corsi N - Z > Reti di calcolatori > esame laboratorio socket
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
fofo
.amico.

User info:
Registered: Mar 2011
Posts: 29 (0.01 al dì)
Location: milano
Corso: f1x
Anno:
Time Online: 4:58:17 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
esame laboratorio socket

ragazzi sto provando a fare il comando nslookup...do l'host name e con getaddrinfo riesco a trovare l'ip...ma x fare il contrario?!

if ((status = getaddrinfo(argv[1], NULL, &hints, &res)) != 0)
{
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(status));
return 2;
}
printf("IP addresses for %s:\n\n", argv[1]);
for(p = res;p != NULL; p = p->ai_next)
{
void *addr;
char *ipver;
char *s,*host;
// si ottiene il puntatore all’indirizzo stesso,
// facendo attenzione ai diversi campi in IPv4 e IPv6:
if (p->ai_family == AF_INET)
{ // IPv4
struct sockaddr_in *ipv4 = (struct sockaddr_in *)p->ai_addr;
s=p->ai_canonname;
addr = &(ipv4->sin_addr);
ipver = "IPv4";



in s avrò l'ip ma io vorrei fare anche il contrario sapete come si fa?

24-01-2012 21:14
Click Here to See the Profile for fofo Click here to Send fofo a Private Message Find more posts by fofo Add fofo to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
CowBoy
.arcimaestro.

User info:
Registered: May 2006
Posts: 294 (0.04 al dì)
Location: Milano
Corso: F49 - Informatica
Anno: Laureato F49
Time Online: 3 Days, 13:40:27 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Prova a dare un'occhiata qua: http://www.gsp.com/cgi-bin/man.cgi?...c=gethostbyaddr

EXAMPLES

Print out the hostname associated with a specific IP address:
const char *ipstr = "127.0.0.1";
struct in_addr ip;
struct hostent *hp;

if (!inet_aton(ipstr, &ip))
errx(1, "can’t parse IP address %s", ipstr);


if ((hp = gethostbyaddr((const void *)&ip,
sizeof ip, AF_INET)) == NULL)
errx(1, "no name associated with %s", ipstr);


printf("name associated with %s is %s\n", ipstr, hp->h_name);

__________________
.. ±·ø·±-`` MuSiC iS My LanGuAGe ´´-±·ø·± ..

Last edited by CowBoy on 25-01-2012 at 12:18

25-01-2012 12:16
Click Here to See the Profile for CowBoy Click here to Send CowBoy a Private Message Find more posts by CowBoy Add CowBoy to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
fofo
.amico.

User info:
Registered: Mar 2011
Posts: 29 (0.01 al dì)
Location: milano
Corso: f1x
Anno:
Time Online: 4:58:17 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

grazie avevo intenzione di utilizzare la struttura hostent....non sappiamo ancora comìè andato lo scritto e nn credo per ora di scrivere da zero un codice per un banale client o server....io mi sento nella merda...

25-01-2012 16:56
Click Here to See the Profile for fofo Click here to Send fofo a Private Message Find more posts by fofo Add fofo to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
fofo
.amico.

User info:
Registered: Mar 2011
Posts: 29 (0.01 al dì)
Location: milano
Corso: f1x
Anno:
Time Online: 4:58:17 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

PERFETTO FUNZIONA ....GRAZIE TANTE...AVEVO PROVATO VON getnameinfo ma era un casino...ora bisogna implementare i server...speriamo di riuscirci

25-01-2012 20:12
Click Here to See the Profile for fofo Click here to Send fofo a Private Message Find more posts by fofo Add fofo to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 09:29.    Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.086 seconds (72.60% PHP - 27.40% MySQL) con 23 query.