最新消息:

有用的代码小片段1–主机名->IP

C/C++ admin 2731浏览 0评论
1
2
3
4
5
6
7
  struct hostent *host;
  struct sockaddr_in serv_addr;
  host = gethostbyname(argv[1]));
  serv_addr.sin_family = AF_INET;
  serv_addr.sin_port = htons(9999);
  serv_addr.sin_addr = *((struct in_addr *)host->h_addr);
  bzero(&(serv_addr.sin_zero),8);

转载请注明:爱开源 » 有用的代码小片段1–主机名->IP

您必须 登录 才能发表评论!