如何检测LAN上的ip和端口并在同一应用程序的列表视图中显示

时间:2015-04-02 04:58:39

标签: vb.net client-server

如何检测来自同一应用程序的ip和端口并显示到列表视图?

这是我使用的代码和我安装到多台计算机的应用程序。

Imports System.IO
Imports System.Threading
Imports System.Net.Sockets
Imports System.Net

Public Class frmutama
    Dim rn As New Random
    Dim rnres = (rn.Next(8000, 8888))
    Dim listener As New TcpListener(rn.Next(8000, 8888))
    Dim client As TcpClient
    Dim message As String

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim hostname As String = Dns.GetHostName()
        Dim ipaddress As String = CType(Dns.GetHostByName(hostname).AddressList.GetValue(0), IPAddress).ToString
        lip.Text = ipaddress
        lports.Text = rnres
        listener.Start()
    End Sub

    Private Sub lvuser_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lvuser.SelectedIndexChanged
        If lvuser.SelectedItems.Count > 0 Then
            frmmsg.Text = lvuser.SelectedItems(0).SubItems(1).Text
        End If
    End Sub
End Class

我想问的是如何检测已安装的应用程序的IP和端口,并在列表视图中显示它们。

任何人都可以提供帮助吗?

谢谢

0 个答案:

没有答案