BACKRUSH  À¯´Ð½º¸í·É  ´ÙÀ½  ÀÚ·á½Ç  Ascii Table   ¿ø°ÝÁ¢¼Ó  ´Þ·Â,½Ã°£   ÇÁ·Î¼¼½º   ½©
ÁöÇÏö³ë¼±   RFC¹®¼­   SUN FAQ   SUN FAQ1   C¸Þ´º¾ó   PHP¸Þ´º¾ó   ³Ê±¸¸®   ¾Æ½ºÅ°¿ùµå ¾ÆÀÌÇǼ­Ä¡

±Û¾´ÀÌ: hostent hostent ±¸Á¶Ã¼ Ãâ·ÂÇÁ·Î±×·¥ Á¶È¸¼ö: 8413


#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>

void main(int argc, char *argv[]) {
struct hostent *myhost;
struct in_addr myinaddr; /* IP ÁÖ¼Ò¸¦ ÀúÀåÇÒ ±¸Á¶Ã¼ */
int i;

if( argc < 2 ) {
printf( "»ç¿ë¹ý : %s host_name(µµ¸ÞÀÎ ³×ÀÓ) \n", argv[0] );
exit(1);
}

/* hostent ±¸Çϱâ */
myhost = gethostbyname( argv[1] );
if (myhost == 0) {
printf("error occurs... at 'gethostbyname'. \n\n\n");
exit(1);
}

/* È£½ºÆ® À̸§ Ãâ·Â */
printf("official host name : \t\t%s\n", myhost->h_name);
/* È£½ºÆ® º°¸í Ãâ·Â */
i = 0;
while(myhost->h_aliases[i] != NULL) {
printf( "aliases name : \t\t%s\n", myhost->h_aliases[i] );
i++;
}

/* È£½ºÆ® ÁÖ¼Ò Ã¼°è Ãâ·Â */
printf("host address type : \t\t%d\n", myhost->h_addrtype);
/* È£½ºÆ® ÁÖ¼Ò ±æÀÌ Ãâ·Â */
printf("length of host address : \t%d\n", myhost->h_length);
/* È£½ºÆ® ÁÖ¼Ò¸¦ dotted decimal ÇüÅ·ΠÃâ·Â */
i = 0;
while( myhost->h_addr_list[i] != NULL ) {
myinaddr.s_addr = *( (u_long *)(myhost->h_addr_list[i]) ) ;
printf("address for host : \t\t%s\n", inet_ntoa(myinaddr)) ;
i++;
}
}

°ü·Ã±Û : 1 °Ç ±Û¾´½Ã°£ : 2002/11/14 16:15 from 218.154.16.35

 

Á¦ ¸ñ

Á¶È¸

³¯Â¥

±Û¾´ÀÌ

hostent ±¸Á¶Ã¼ Ãâ·ÂÇÁ·Î±×·¥

8413

2002.01.19

hostent


  daytime client (Tcp) ¸ñ·Ïº¸±â »õ±Û ¾²±â Áö¿ì±â ÀÀ´ä±Û ¾²±â ±Û ¼öÁ¤ È£½ºÆ® ¹ÙÀÌÆ®¼ø¼­ Å×½ºÆ® ÇÁ·Î±×·¥  
BACKRUSH  À¯´Ð½º¸í·É  ´ÙÀ½  ÀÚ·á½Ç  Ascii Table   ¿ø°ÝÁ¢¼Ó  ´Þ·Â,½Ã°£   ÇÁ·Î¼¼½º   ½©
ÁöÇÏö³ë¼±   RFC¹®¼­   SUN FAQ   SUN FAQ1   C¸Þ´º¾ó   PHP¸Þ´º¾ó   ³Ê±¸¸®   ¾Æ½ºÅ°¿ùµå ¾ÆÀÌÇǼ­Ä¡