Windows Firewall -- a native Windows 8 and 7.1 application -- lets you block network ports to prevent your computer from sending or receiving data through them. Blocking a port using Windows Firewall requires you to create a new security rule and customize its settings using a wizard.
Open the Start Screen under Windows 8.1 or the Start Menu under Windows 7 and type Firewall in the search bar. Select Windows Firewall from the list of results to open the Windows Firewall application.
Click on Advanced Settings in the sidebar.
Select either Inbound Rules from the sidebar if you want to prevent your computer from receiving data through a specific port or Outbound Rules to prevent it from sending data through that same port.
If your security concerns you, blocking inbound traffic is probably the most suitable option as it helps prevent third-parties -- including potentially malicious users -- from sending data to your computer through open ports.
In some cases, however, blocking outbound traffic may be more appropriate -- for example, to prevent a program on your computer from sending data over the Internet, or if you have received complaints from your Internet service provider regarding spam sent by malware installed on your computer.
Open the Action menu and select New Rule to open the New Rule wizard.
Select Port and click on Next.
Select either TCP to block transmission control protocol data or UDP if you would rather block user datagram protocol data. UDP and TCP are the two main protocols that programs use to communicate over the Internet. While some programs rely on a single protocol, many others use both TCP and UDP, depending on which data they need to send or receive.
To block a program from receiving or sending data, a Google search can help you find out which protocol that particular program uses. Alternatively, if you are unsure which protocol to block, consider blocking both UDP and TCP traffic by creating two separate rules -- one for TCP and one for UDP.
Enter the port number you want to block next to Specific Local Ports and click on Next. Alternatively, enter a port range in the X-Y format to block all ports between numbers X and Y. For example, enter 4000-4100 to block all ports in that range.
Select Block the Connection and click on Next.
Select Next. Optionally, untick one or several of the check boxes if you do not want Windows Firewall to block the selected port when your computer is connected to a specific network type. For example, if you want the port to remain open while your computer is connected to a network you labeled as private, untick the second check box.
Name your new rule and click on Finish to save your new rule. Optionally, enter a description in the text field, for example, to help you remember in a few months or years why you created that rule.