Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do applications connect to servers without the need of portforwarding?

I just created a simple chat client and it only works when all clients / server are portforwarded on the same port.

How do i make my application (its in c# and uses .net sockets btw) work without the need of port forwarding for clients (i dont care if server needs to port forward).

it uses udp by the way.

like image 363
Dan Webster Avatar asked Sep 25 '12 21:09

Dan Webster


1 Answers

I believe you titled your question wrong. You are talking about the server connecting to the client, right?

If you are working directly with sockets, the short answer is - you can't. The long answer is that the client has to register with server in such a way that the client port is held open so the server can reach it.

Rather than writing this yourself, consider a library that is focused on this, such as SignalR.

Besides - UDP is a horrible choice for a chat client anyway. There are plenty of jokes about UDP packets, but trust me - you won't get them all.

like image 102
Matt Johnson-Pint Avatar answered Sep 17 '22 17:09

Matt Johnson-Pint