我使用套接字编程创建了监控应用程序web。我通过IP地址获取客户端计算机的状态连接有问题。我不知道如何通过网络展示它。这是我的代码:
private String GetIp()
{
String strHostName = Dns.GetHostName();
// Find host by name
IPHostEntry iphostentry = Dns.GetHostByName(strHostName);
// Grab the first IP addresses
String IPStr = "";
foreach (IPAddress ipaddress in iphostentry.AddressList)
{
IPStr = ipaddress.ToString();
return IPStr;
}
return IPStr;
}
private void loadIP()
{
DataTable dt = new DataTable();
dbCon = new DBConnect2();
dt = new DataTable();
dt = dbCon.selectdata();
for (int i = 0; i < dt.Rows.Count; i++)
{
ListBox1.Items.Add(dt.Rows[i][0].ToString());
}
}
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Text = GetIp();
loadIP();
TextBox1.Text += "---" + m_workerSocketList.Count + "\n";
if(m_workerSocketList.Count>0)
{
string s = "";
for (int i = 0; i < m_workerSocketList.Count; i++)
{
s = s + "ip : = " + m_workerSocketList[i].ToString() + "\n";
}
TextBox1.Text += s;
}
TextBox1.Text += "---\n";
}
拜托,我真的需要你的帮助。谢谢。