I've made several games in VB successfully and am now ready to move on to attempt making multiplayer games. However, as I have no experience of doing this and can find little on the internet to assist me, I have a problem I can't find the solution to. I'm using VB as the language, although I've put c#
in the tags because I can understand solutions using it instead.
I've attempted to make a game 2-player by using TCP to connect between the players.
It uses the TcpListener
class for the server code and the TcpClient
class for the client code and pretty much uses the template which th documentation gives: server, client.
The server:
server = New TcpListener(IPAddress.Any, 48000)
And the client:
Dim client As New TcpClient()
client.Connect(hostAddr, 48000)
I'm testing out the code using both server and client on the same machine. The code works perfectly fine when I make hostAddr
the local IP address of my computer and I can successfully send messages between the 2 programs.
However, when I give hostAddr
my external IP address the client code fails to work because of the error: 'No connection could be made because the target machine actively refused it'.
I have tried the following which don't work for me:
Switching off the firewall
Changing my router settings to allow TCP connections through all ports
I am using Windows 10 in a VM (I hope this doesn't affect things).
Could I have some suggestions as to what else could be going wrong, and how I should debug to find out if they are true? In addition, I would like to know if I would encounter similar problems if I were to ask a friend to run the client on their computer (which is not on the same network).