0

I am working in a project in my school where we are programming an multiplayer online game. I am working on the connection between server and client and i have stumble upon on a problem that i hope you can assist me with.

So i have an working TCP connection between server and clients that grabs the clients ip give them an id on the server. When connection is established between 4 clients and the server the game starts and i switch to UDP connection because a lot of packages will be sent.

/* Problem */

The problem i am having is that the clients can send UDP packages to the server which then redirects it to the clients. But some clients on different computers blocks windows firewall the incoming UDP packages from the server. So client to server works but not server to clients. When i disable windows firewall then everything works.

How do i make an exception in the firewall or prompt the message that let's the user decide if they accept the incoming connection?

too honest for this site
  • 12,050
  • 4
  • 30
  • 52
Johnboll
  • 55
  • 9
  • Possible duplicate of [Programmatically add an application to Windows Firewall](http://stackoverflow.com/questions/113755/programmatically-add-an-application-to-windows-firewall) – Alex K. May 13 '16 at 11:54

1 Answers1

1

So i found a solution to my problem. My problem was that i let my computer decide which UDP port it wanted to use however this didn't trigger the Firewall just blocked it so i did put in a "fake" socket which alerted the firewall so they user could agree too let my software use the Port and after that let the computer decide.

(initUDPSocket is my own made fucntion not including in SDL_Net)

UDPpacket *p;
UDPsocket UDPsd, testsd;

testsd = initUDPSocket(11111); /* This socket alerts the firewall and ask for permission */

SDLNet_UDP_Close(testsd);
testsd=NULL; //this helps us know that this UDPsocket is not valid anymore

/*Open a UDP socket for reaching server from client */
UDPsd = initUDPSocket(0);             /* 0 = port value, 0 = any available port on the computer */
Johnboll
  • 55
  • 9