#pragma comment(lib,"ws2_32.lib")
#include //將cstring 型ip位址在ipaddressctrl中顯示
cstring strip="192.168.0.10";
dword dwip;
dwip = inet_addr(strip);
unsigned char *pip = (unsigned char*)&dwip;
m_ipaddr.setaddress(*(pip+3), *(pip+2), *(pip+1), *pip);
//將ipaddressctrl中的ip位址獲得並轉換成cstring型
unsigned char *pip;
cstring strip;
dword dwip;
m_ipaddr.getaddress(dwip);
pip = (unsigned char*)&dwip;
strip.format("%u.%u.%u.%u",*(pip+3), *(pip+2), *(pip+1), *pip);
或者有乙個簡單的:
cstring strip="192.168.1.184";
dword dwaddress= ntohl( inet_addr(strip));
m_ipaddr.setaddress(dwaddress);
// dword ip轉換為cstring
dword dwmainserverip;
m_mainserveripctrl.getaddress(dwmainserverip);
strmainserverip.format(_t("%d.%d.%d.%d"),
(dwmainserverip>>24)&0xff,
(dwmainserverip>>16)&0xff,
(dwmainserverip>>8)&0xff,
dwmainserverip&0xff ) ;
**:
MAC位址和IP位址
裝置的mac位址是出廠就設定好的,每台裝置的mac位址都是全球唯一的。在osi open system interconnection,開放系統互連 7層網路協議 物理層,資料鏈路層,網路層,傳輸層,會話層,表示層,應用層 參考模型中,第二層為資料鏈路層 data link 它包含兩個子層,上一層是...
IP位址和MAC位址
mac位址 ip位址就是給每個連線在internet上的主機 或路由器 分配乙個在全世界範圍內唯一的32位標識為。ip位址因其特殊的結構使我們可以在網際網路上很方便地進行定址。這裡所說的唯一標識是指給連到網際網路上的最終裝置分配的。在本文章中,預設介紹ipv4位址。根據網路號的不同,將ip位址分為5...
閘道器IP位址和IP位址的區別
閘道器,大家都知道,從乙個房間走到另乙個房間,必然要經過一扇門。同樣,從乙個網路向另乙個網路傳送資訊,也必須經過一道 關口 這道關口就是閘道器。顧名思義,閘道器 gateway 就是乙個網路連線到另乙個網路的 關口 按照不同的分類標準,閘道器也有很多種。tcp ip協議裡的閘道器是最常用的,在這裡我...