开发者

C# How to connect a TCPListener (server) behind a router

开发者 https://www.devze.com 2023-01-23 14:16 出处:网络
I have a client and server application in two computers. i am trying to connect them through internet TCP connection. the problem im facing is.

I have a client and server application in two computers. i am trying to connect them through internet TCP connection. the problem im facing is.

Client (192.168.1.2) -> [router] (124.43.224.112) --

-> (internet) -> [router] (124.43.190.63) -> Server (192.16开发者_如何转开发8.1.3)

How do i establish a TCP connection ?


Internet 101:

  • Network Address Translation http://en.wikipedia.org/wiki/Network_address_translation
  • Port Forwarding http://en.wikipedia.org/wiki/Port_forwarding

The router 124.43.190.63 must be configured to do port forwarding to 192.168.1.3. Client connects to 124.43.190.63.

You must understand these basics if you're writing a networking application.


In order for the client to connect to a server that is hidden behind a router you need to setup port forwarding on the server's router. That way when the client attempts to connect to a configured port on the server's router, the request is forwarded onto the server.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号