Adding an exception to Windows Firewall
Windows Firewall protects us from hackers that might try to connect to random ports on our computer. However, if we want to allow our own programs to receive messages, we'll need to add exceptions to the firewall to let them through. In this recipe, we'll install a console application that listens on a certain port and then add this program to the list of applications that are allowed to have incoming messages pass through the firewall.
Getting ready
So that we're able to test our firewall exception, let's create a console application that will listen on a TCP port. Ordinarily, if anyone on a different computer tried to access that port to send a request, it would be blocked by the firewall. Perform the following steps to set up the application and include it in our installer:
- Create a new C# Console Application project named
PortListeningProgram
and add the following code to itsProgram.cs
file:using System; using System.IO; using...