91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

如果要在程序里面用到自己的外網IP,可以下載這個DEMO. 原理很簡單,碼也少,巧用某網站即可. VC6,VS2010編譯測試通過

資源截圖

代碼片段和文件信息

//?AAA.cpp:?implementation?of?the?AAA?class.
//?Download?by?http://www.codefans.net
//////////////////////////////////////////////////////////////////////

#include?“stdafx.h“
#include?“TestForNetInfo.h“
#include?“AAA.h“

#ifdef?_DEBUG
#undef?THIS_FILE
static?char?THIS_FILE[]=__FILE__;
#define?new?DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
//?Construction/Destruction
//////////////////////////////////////////////////////////////////////
#include?
#include?
AAA::AAA()
{

}

AAA::~AAA()
{

}

CString?AAA::GetRIP()
{
CString?csRes?=?“error“;
WSAData?wsaDat;
short?int?Port?=?80;
WSAStartup(MAKEWORD(11)&wsaDat);
SOCKET?sd?=?socket(AF_INET?SOCK_STREAM?0);
SOCKADDR_IN?sockAddr;
memset((void*)&sockAddr0sizeof(sockAddr));
sockAddr.sin_family=AF_INET;
sockAddr.sin_port=htons(Port);
sockAddr.sin_addr.s_addr=inet_addr(“219.153.18.104“);
connect(sd(LPSOCKADDR)&sockAddrsizeof(sockAddr));
char?sendstr[]=“GET?/ip2city.asp?HTTP/1.1\r\nAccept:?*/*\r\nReferer:?******\r\nUser-Agent:?Mozilla/4.0\r\nHost:?www.ip138.com\r\nConnection:?close\r\n\r\n\0“;
char*?p;
int?iLen?=?strlen(sendstr);
p?=?sendstr;
while?(iLen){
int?iRet?=?send(sdpiLen0);
if?(iRet?>?0)?{
p?+=?iRet;
iLen?-=?iRet;
continue;
}
return?csRes;
}
char?recvstr[1024];
memset(recvstr01024);
p?=?recvstr;
char*?iIndex_Head?;
iLen?=?1024;
int?need_len?=?-1;
while?(iLen){
int?iRet?=?recv(sdpiLen0);
if?(iRet?<=?0)?{
return?csRes;
}
p?+=?iRet;
iLen?-=?iRet;
if?((iIndex_Head?=?strstr(recvstr“\r\n\r\n“))&&(need_len==-1))?{
char*?iIndex?=?strstr(recvstr“Content-Length:“);
if?(!iIndex)?{
continue;
}
char?*p1?=??iIndex?+?strlen(“Content-Length:“);
need_len?=?iIndex_Head?-?recvstr?+?2?+?atol(p1);

}
if?(1024?-?iLen?>=need_len)?{?break;
????????
}
}
char?*p1?=?strstr(iIndex_Head“[“);
char?*p0?=?strstr(p1“]“);
*p0?=?‘\0‘;
printf(“IP=%s“p1+1);
closesocket(sd);
WSACleanup();
csRes?=?&(p1[1]);
return?csRes;
}

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????2134??2010-11-23?16:49??GetWanIP\AAA.cpp
?????文件?????????486??2010-11-23?14:58??GetWanIP\AAA.h
?????文件????????3723??2010-11-23?14:54??GetWanIP\ReadMe.txt
?????目錄???????????0??2014-11-10?14:09??GetWanIP\res\
?????文件????????1078??2010-11-23?14:54??GetWanIP\res\TestForNetInfo.ico
?????文件?????????406??2010-11-23?14:54??GetWanIP\res\TestForNetInfo.rc2
?????文件?????????692??2010-11-23?14:55??GetWanIP\resource.h
?????文件?????????216??2010-11-23?14:54??GetWanIP\StdAfx.cpp
?????文件????????1090??2010-11-23?16:49??GetWanIP\StdAfx.h
?????文件???????20824??2010-11-23?15:15??GetWanIP\TestForNetInfo.aps
?????文件????????1136??2010-11-23?15:16??GetWanIP\TestForNetInfo.clw
?????文件????????2211??2010-11-23?16:49??GetWanIP\TestForNetInfo.cpp
?????文件????????4446??2010-11-23?15:16??GetWanIP\TestForNetInfo.dsp
?????文件?????????536??2010-11-23?14:54??GetWanIP\TestForNetInfo.dsw
?????文件????????1412??2010-11-23?14:54??GetWanIP\TestForNetInfo.h
?????文件????????5266??2010-11-23?14:55??GetWanIP\TestForNetInfo.rc
?????文件????????4384??2010-11-23?16:49??GetWanIP\TestForNetInfoDlg.cpp
?????文件????????1494??2010-11-23?16:49??GetWanIP\TestForNetInfoDlg.h
?????文件??????????50??2010-11-23?15:18??GetWanIP\說明.txt

評論

共有 條評論