Vb.net 如何在家中测试网络编程解决方案?

Vb.net 如何在家中测试网络编程解决方案?,vb.net,testing,network-programming,Vb.net,Testing,Network Programming,我有一个用于在线多玩数独的程序。我已经编写了专门用于在应用程序实例之间设置特定tcpclient连接的代码,但当我尝试使用本地主机IP:127.0.0.1对其进行测试时,收到了错误消息: 无法建立连接,因为目标计算机主动拒绝连接 就在尝试设置客户端时。不管怎样,它使用与发送相同的端口进行侦听,因此稍后此方法会遇到问题,但我需要测试我的解决方案,因此我问:在家测试网络程序最简单的方法是什么时间是一个因素。我可以访问以下内容: 需要1台通过xampp数据库安装数据库的计算机 最多可以安装2台没有数据

我有一个用于在线多玩数独的程序。我已经编写了专门用于在应用程序实例之间设置特定tcpclient连接的代码,但当我尝试使用本地主机IP:127.0.0.1对其进行测试时,收到了错误消息:

无法建立连接,因为目标计算机主动拒绝连接

就在尝试设置客户端时。不管怎样,它使用与发送相同的端口进行侦听,因此稍后此方法会遇到问题,但我需要测试我的解决方案,因此我问:在家测试网络程序最简单的方法是什么时间是一个因素。我可以访问以下内容:

需要1台通过xampp数据库安装数据库的计算机

最多可以安装2台没有数据库的其他计算机

多谢各位

编辑:


这就是我初始化客户机的方式。在子节点中,单击datagridview单元格,HostAddress以字符串形式包含主机的IP地址。这是发生异常的第二行。

您提供的信息太少,无法实际帮助您查找错误,但以下是如何尝试在您的PC上使用localhost上的基本连接。创建两个控制台项目,一个是客户端,一个是服务器,并插入以下代码:

客户

服务器

编译并启动项目。一旦服务器启动,它就开始侦听本地主机上的端口6583。启动客户端并按下一个键,您会看到消息,说明连接正常。
如果是这样,您的代码就是错误的。如果没有,您应该检查防火墙设置和类似的内容。

请提供有关如何启动和接受网络连接的代码。例如,我使用TCPClient和TCPListener连接本地主机时从未遇到过问题。
      'sets the destination IP to the HostAddress
    IP = sender.CurrentRow.Cells.Item("HostAddress").Value
    'creates a new instance of a client for send and recieving streams
    client = New TcpClient(IP, port)
Imports System.Net.Sockets
Imports System.Net
Module Client
Sub Main()
    Dim IP As IPAddress = IPAddress.Parse("127.0.0.1")
    Console.WriteLine("Start server and then press any key to connect.")
    Console.ReadKey()
    Console.WriteLine("Connecting...")
    Dim client As New Net.Sockets.TcpClient
    client.Connect(IP, 6583)
    Console.WriteLine("Connected!")
    Console.ReadKey()
    client.Close()
End Sub
End Module
Imports System.Net.Sockets
Imports System.Net
Module Server
Sub Main()
    Dim IP As IPAddress = IPAddress.Parse("127.0.0.1")
    Dim server As New TcpListener(IP, 6583)
    server.Start()
    Console.WriteLine("Waiting for connection...")
    While server.Pending = False
    End While
    Dim connectedclient As TcpClient = server.AcceptTcpClient
    Console.WriteLine("Client connected. Nice.")
    Console.ReadKey()
End Sub
End Module