I have created a simple tcp client-server application in vb.net. Everything works fine when i set *local host* (127.0.0.1) as the ip address. I wish to make a connection to a remote machine (keeping client at my machine and server on the other - or vice versa).
ok, the code of interest is as follows:
Dim server As TcpListener = New TcpListener(IPAddress.Any, port)
Dim theip As IPAddress = IPAddress.Parse(TextBox1.Text)
client = New TcpClient(theip.ToString, port)
Now, what should i enter in "TextBox1.Text" if i have my client on a remote machine (connected over internet) and server at a different computer (whose external IP address is known)?
Can i enter the external IP address of the machine running the server directly in the text box? Also, do i need to take care of things like "port forwarding" / "let firewall allow the connection" and all? If yes, can you please guide me or link a tutorial so that my application does this automatically or is there an alternative approach to achieve this and so that port forward is not required? Thanks a lot! If you're connecting over internet, port forwarding IS a must, like for all network connections, so the appropriate machine responds to the appropriate port. When connecting on a LAN, you just need to allow outgoing on the client and incoming connections on the server on the firewall. There is no way your program can setup those, it's completely outside of your app responsibilities to do so. You should put clear documentation or guidelines for the user to perform those steps on both PCs. A "test connection" button may help for troubleshooting.
以上就是Connecting to a remote machine through client-server的详细内容，更多请关注web前端其它相关文章！