windows下gethostbyname函式使用

2022-09-12 18:03:22 字數 1115 閱讀 7338

//

這是用來測試乙個gethostbyname函式 用於使用網域名稱獲取ip

#include#include

#pragma comment(lib,"ws2_32.lib") #include

#pragma comment(lib,"ws2_32.lib")#include

/*struct hostent;*/

int main(void);

wsadata wd;

//win下面必須這樣 因為懶得開linux所以就用vs

if(wsastartup(makeword(2,2),&wd) != 0) //

wsastartup

//檢查返回值錯誤問題

if((ent = gethostbyname(ptr)) ==null)

fprintf(stdout ,

"h_name:%s\n

" , ent->h_name);

while(ent->h_aliases[i])

fprintf(stdout ,

"h_aliases[i%d]:%s\n

",i , ent->h_aliases[i++]);

fprintf(stdout ,

"h_addrtype : %s\n

" ,(ent->h_addrtype == af_inet)?"

ipv4

":"ipv6");

fprintf(stdout ,

"h_length : %h\n

" , ent->h_length);

//將ent結構體中的網路位元組序轉成 主機位元組序

inetntop(ent->h_addrtype , ent->h_addr_list[0], src , 32

);

//inetntop(

if(src[0] ==null)

fprintf(stdout ,

"h_addr: %s\n

", src);

system(

"pause");

exit(0);

}

windows下CoffeeScript 的實現

安裝coffeescript,需要先安裝node.js和npm。在mac 和 linux 的環境下,coffeescript的安裝是相當容易的。比較複雜的呢是在windows的環境下安裝。所以我們著重講一下在windows環境下的安裝方式。安裝完node 包括npm 後,我們到programm fi...

windows下python twisted庫安裝

方式 一 命令列中執行easy instal twisted 提示 unable to find vcvarsall.bat 的錯誤,這是因為twisted源 安裝方式,需要c編譯環境,如果有安裝vc開發環境就可以通過 plain view plain copy 首先安裝mingw,在mingw的安...

Windows下chromedriver安裝與配置

chromedriver 谷歌瀏覽器驅動 谷歌瀏覽器 幫助 關於 chrome 注意 chromedriver 的版本要和 chrome 瀏覽器相對應,不然很多功能不能用 從selenium中匯入webdriver from selenium import webdriver 建立乙個瀏覽器驅動 e...