Is it possible to use TCPclient and TCPlistener in c# with public IP addresses (or outside my LAN)? If NAT randomly assigns port number to each LAN communication, is there any way to know what port-number will be assigned to TCPlistener by its NAT-router to make TCPclient be able to communicate with it. P.S. If it's not possible is there any other tool/technique to communicate outside the LAN without reconfiguring router (to forward all the messages to TCPlistener)?
Asked
Active
Viewed 163 times
0
-
1The long and short answer is: NO!. – Eldar Aug 14 '20 at 10:55
-
Nat traversal is possible. Not seen it done much with TCP. Some resources - https://stackoverflow.com/questions/2443471/tcp-hole-punch-nat-traversal-library-or-something https://github.com/jasonpang/tcp-holepunching – Jason Aug 14 '20 at 12:29
1 Answers
1
Have a look at
TcpListener.AllowNatTraversal
This can be done with Toredo, 6to4, or an ISATAP tunnel.
Another option is UPnP if your NAT device supports it.

Rowan Smith
- 1,815
- 15
- 29