📄 subject_40055.htm
字号:
<p>
序号:40055 发表者:夏天和小凡 发表日期:2003-05-15 14:32:41
<br>主题:我用gethostbyaddr()的时候老是出错。不知道为什么。
<br>内容: 我用gethostbyaddr()的时候老是出错。不知道为什么。<BR> char name[20];<BR> host_entry = gethostbyaddr( name, strlen(name), AF_INET );<BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:syncmaster 回复日期:2003-05-16 12:13:27
<br>内容:CString CMainFrame::getHostIp()<BR>{<BR> char szHostName[128];<BR>// char szT[20];<BR> CString ipAddr;<BR> CString temp;<BR> if( gethostname(szHostName, 128) == 0 )<BR> {<BR> // Get host adresses<BR> //m_HostName.SetWindowText(szHostName);<BR> struct hostent * pHost; <BR> int i; <BR> pHost = gethostbyname(szHostName); <BR> for( i = 0; pHost!= NULL && pHost->h_addr_list[i]!= NULL; i++ ) <BR> {<BR> //char str[100]; <BR> //char addr[20];<BR> // int j; <BR> LPCSTR psz=inet_ntoa (*(struct in_addr *)pHost->h_addr_list[i]);<BR> temp.Format("%s",psz);<BR> ipAddr+=temp;<BR> }<BR> <BR><BR> }<BR> return ipAddr;<BR>}<BR>这是我写的获得ip的代码,看看有没有用
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:dr0 回复日期:2003-05-16 19:46:12
<br>内容:maybe u have forgotten to initialize winsock dll<BR>call WSAStartup() first.
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:夏天和小凡 回复日期:2003-05-16 22:37:04
<br>内容:gethostbyname != gethostbyaddr<BR><BR>I have called the WSAtartup()!
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:Neil Gan 回复日期:2003-05-18 01:22:57
<br>内容:char name[20];<BR>//127.0.0.1<BR>name[0]=127;<BR>name[1]=0;<BR>name[2]=0;<BR>name[3]=1;<BR>HOSTENT *host_entry = gethostbyaddr( name, 4, AF_INET );<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -