小女求助,如何得到自己电脑在网络中的IP地址及端口号,谢谢帮忙 小女求助,如何得到自己电脑在网络中的IP地址及端口号,谢谢帮忙 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 IP简单,"不过本机端口"--指的什么? 是port吗?port只是应用层概念,本机可以有0~~25565(好像是吧)号端口不用来表示计算机.这样说你明白吗.*****************************get local ip source code**************** char szhost[256] = {0}; HOSTENT *host = 0; in_addr HostIP = {0}; SOCKADDR_IN ip = {0}; if(!gethostname(szhost,256)) AfxMessageBox(szhost); host = gethostbyname( szhost ); if(host) { AfxMessageBox(host->h_name); memcpy(&HostIP, host->h_addr_list[0], sizeof(in_addr)); ip.sin_addr.S_un.S_addr = ntohl(HostIP.S_un.S_addr); AfxMessageBox( inet_ntoa(HostIP) ); }*************************** end ************************************** CString GetIp(){ WORD wVersionRequested; WSADATA wsaData; char name[255]; CString ip; PHOSTENT hostinfo; wVersionRequested = MAKEWORD( 2, 0 ); if ( WSAStartup( wVersionRequested, &wsaData ) == 0 ) { if( gethostname ( name, sizeof(name)) == 0) { if((hostinfo = gethostbyname(name)) != NULL) { ip = inet_ntoa (*(struct in_addr *)*hostinfo->h_addr_list); } } WSACleanup( ); } return ip;}端口不知, 用端口扫描软件扫吧或者笨办法, bind windows 当前登录用户 标识 写了个简易的ssl客户端,跨平台 关于CStatic静态文本框和CEditBox编辑框文本颜色的问题 使用CWebbrowser怎么禁止脚本运行 请教; Unicode下如何将CString字符串转换为整数? 鼠标拖动窗口在屏幕上移动(没到边界),除了响应OnSysCommand,还响应别的什么函数? Bitmap的屏蔽色 关于用VC操作access的问题,搞了两天搞不好,郁闷啊,急急急啊 如何在vc代碼中訪問一個控件的屬性 阿修罗请进。你的邮箱有问题。所以我把整个源代码上传了。你到那里去下载吧 vc++编程 心情不好!散分!
这样说你明白吗.
*****************************get local ip source code****************
char szhost[256] = {0};
HOSTENT *host = 0;
in_addr HostIP = {0};
SOCKADDR_IN ip = {0};
if(!gethostname(szhost,256))
AfxMessageBox(szhost);
host = gethostbyname( szhost );
if(host)
{
AfxMessageBox(host->h_name);
memcpy(&HostIP, host->h_addr_list[0], sizeof(in_addr));
ip.sin_addr.S_un.S_addr = ntohl(HostIP.S_un.S_addr);
AfxMessageBox( inet_ntoa(HostIP) );
}
*************************** end **************************************
{
WORD wVersionRequested;
WSADATA wsaData;
char name[255];
CString ip;
PHOSTENT hostinfo;
wVersionRequested = MAKEWORD( 2, 0 ); if ( WSAStartup( wVersionRequested, &wsaData ) == 0 )
{ if( gethostname ( name, sizeof(name)) == 0)
{
if((hostinfo = gethostbyname(name)) != NULL)
{
ip = inet_ntoa (*(struct in_addr *)*hostinfo->h_addr_list);
}
}
WSACleanup( );
}
return ip;
}端口不知, 用端口扫描软件扫吧
或者笨办法, bind