c# 用GetHostAddresses或者GetHostEntry 得到集群对外的虚拟IP

oneatree 2010-08-19 02:29:07
string strHostName = Dns.GetHostName(); //得到本机的主机名
IPHostEntry ipEntry = Dns.GetHostEntry(strHostName); //取得本机IP
bool ischange = true;
string path = Application.StartupPath;
for (int i = 0; i < ipEntry.AddressList.Length; i++)
{
string strAddr = ipEntry.AddressList[i].ToString();

或者
ips = Dns.GetHostAddresses(strHostName); //取得本机IP

string path = Application.StartupPath;
for (int i = 0; i < ips.Length; i++)
{
string strAddr = ips[i].ToString();

都不得不到
但用mfc写的程序可以得到
...全文
260 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
oneatree 2011-01-14
  • 打赏
  • 举报
回复
你能得到虚拟机对外的IP
ouyang4683 2010-12-06
  • 打赏
  • 举报
回复
.。。。为啥我都得到了。。。
没什么错误啊
oneatree 2010-08-20
  • 打赏
  • 举报
回复
来人呢
oneatree 2010-08-19
  • 打赏
  • 举报
回复
来人呢
oneatree 2010-08-19
  • 打赏
  • 举报
回复
用ipconfig命令 也能看到对外的集群的虚拟IP

111,098

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧