0

How can i send data from server to nat users? I have own implementation for transfer data by tcp/ip but it work only between computers with public ip address.

I hear about udp but i dont know it is only way to do this?

Thanks for any suggestions.

Sending data to nat user over c#

sglogowski
  • 321
  • 3
  • 12
  • Most solutions involve both clients connecting to a public server, and the data exchange being brokered through there. UDP is no magic to breaking NAT. – Joe Nov 26 '13 at 18:57
  • I want connect server(public ip) with client(over nat). – sglogowski Nov 26 '13 at 19:00
  • You really can't do that cleanly through NAT in many cases. You will need the client to establish the connection (C->S) and then connect the two users up at the server. – Joe Nov 26 '13 at 19:02

1 Answers1

0

You need to forward the TCP port you're using on the target routers. E.g. on public IP 70.1.1.33 there is an guy with a local IP address of 192.168.1.103. When you want to connect to that one, the guy on 70.1.1.33 has to forward the port (e.g. 1953) on his/her router to the local address 192.168.1.103.

How this is done varies heavily, depending on the router manufacturer. But google will help you out. You can find more information here and here

This question could contain your answer: How do I make a TCP server work behind a router (NAT) without any redirection configuration needed

Community
  • 1
  • 1
LueTm
  • 2,366
  • 21
  • 31
  • Hmmm... it is weak solution for me, i know it will work but if client changes localization he stop receiving data from server, i want create something like dropbox, and i must be able to connect to server from any localisation. – sglogowski Nov 26 '13 at 18:56
  • Well, then you have to make things more complicated. Dropbox uses a server to synchronize, so all participants are **clients**. So you'd have to use a server to negotiate connections. Another solution would be UPNP, but I'd strongly advise against that. VPN would be another workaround. There is just no way to connect otherwise. – LueTm Nov 26 '13 at 18:59
  • Many enterprises block UPNP anyway, so it would be a solution for some people but not a lot. – Joe Nov 26 '13 at 19:02
  • So i see i have problem, i can always send this data by http server, but it is not good solution for me. – sglogowski Nov 26 '13 at 19:14
  • Thanks, i'm reading this and i see that this guy has both machines(client and server) over nat, i have only one machine(client). – sglogowski Nov 26 '13 at 19:44
  • Well.. whatever you do, you can't circument the basic problem, that multiple clients can be behind a NAT. You'll have to use either a negotiating server or use portforwarding in one form or another. Sorry, but that's just the way it is. Downvoting me for it is shooting the messenger. – LueTm Dec 07 '13 at 11:08