The port number is a numeric identifier used to route packets to the correct application on a computer.
Just as Media Access Control (MAC) addresses are used to deliver frames to the correct physical computer or you can say to the network adapter.
And IP Addresses are used to route packets to the correct logical computer (x.x.x.x) , Port numbers are used to route a packet to the correct application after the packet has arrived at its destination computer.
We know that on a single computer/Server their are lots of applications are running.When a packet arrives at that server, it cannot be delivered to ust any application.For example, HTTP client requests are not going to be understood by an LDAP server application.
Port numbers range from 1 to 65,000.Most established Internet protocols have assigned port numbers,reffered to as well-known port numbers.
By this it is easy for firewall to allow or block request on particular port.
For example,if a firewall were configured to block port 80,HTTP clients would not be able to pass through the firewall and communicate with any internal virtual servers.You will have to open specific ports in order to let the proper traffic pass.
For an extra measure of security, you can usually change the port numbers that an application uses.For example,you might change your POP3 virtual server and all POP3 clients too use port 28,345 instead of the default 110.
The drawback of doing this is that you will have to manually chang any application that will need to communicate with the server.