'gethostbyname()'에 해당되는 글 1건

  1. 2010.04.05 gethostname() 과 gethostbyname() - difference of gethostname() and gethostbyname() 4
Linux2010. 4. 5. 18:23
by 하나 차이지만, 큰 차이가 있는 녀석이다.

gethostname()은 자기 자신의 이름을 얻는 함수이고
gethostbyname()은 다른 녀석의 ip를 얻는 함수이다.

#include <unistd.h>
int gethostname(char *name, size_t len);
int sethostname(const char *name, size_t len);

#include <netdb.h>
struct hostent *gethostbyname(const char *name);

#include <sys/socket.h>       /* for AF_INET */
struct hostent *gethostbyaddr(const void *addr, int len, int type);

# cat /usr/include/netdb.h
/* Description of data base entry for a single host.  */
struct hostent
{
  char *h_name;                 /* Official name of host.  */
  char **h_aliases;             /* Alias list.  */
  int h_addrtype;               /* Host address type.  */
  int h_length;                 /* Length of address.  */
  char **h_addr_list;           /* List of addresses from name server.  */
#define h_addr  h_addr_list[0]  /* Address, for backward compatibility.  */
};

[링크 : http://www.joinc.co.kr/modules/moniwiki/wiki.php/man/3/gethostbyname]
[링크 : http://www.joinc.co.kr/modules/moniwiki/wiki.php/man/2/gethostname]

'Linux' 카테고리의 다른 글

wget  (4) 2010.04.10
/dev의 major minor에 대하여  (0) 2010.04.08
chown 사용방법(사용자와 그룹 바꾸기)  (0) 2010.04.03
터미널을 통한 데이터 통신에서 0x11이 사라졌어요  (0) 2010.04.02
ls 용량별로 정렬하기  (0) 2010.04.01
Posted by 구차니