Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I can not connect to the TCP Server when i am on a different network

I am trying to connect to a Tcp server I created on another network, I have had no luck. Is there a way to do this?

What is is the IP Address that i need to put in to the Client program?

The server works fine if you are on the network but how do i connect is i am on a different network?

I have tried to connect with the external IP Address but the message just sat at the router, how do i make the router send the message to my PC?

  • What am i doing wrong
  • How do i fix it
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
171 views
Welcome To Ask or Share your Answers For Others

1 Answer

Your TCP server should be on a system with a public(external) ip address. Clients then will be able to connect to the server even if they are inside a LAN. Note that the ip adresses in a LAN are different from external ip-addresses. The translation is called NAT.

So because your server runs on a computer inside a LAN it will not be accessible for other computers on the internet. Your router on the other hand has a public ip address which will be accessible from the internet. You can configure your router to forward a port to your computer so that your router connects your server with the internet. Note that port forwarding is often a bad security practice. Make sure that you pick a port number that's not used by any other program.

Also keep in mind that the TCP traffic from the client to the server is probably un-encrypted. This means that your traffic will be vulnerable for man-in-the-middle attacks. You should try to establish an connection which uses SSL. (Note: SSL is not equal to https) For more information please look at the OSI-model.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...