I just wanted to know what are ports. Can someone explain to me what a port is?
In network computing, a port is a sub-address. It is like a room number in an hotel: the hotel has an address (e.g. 42 Washington Street, Austin, Texas) and is itself subdivided into rooms, each having its own number (e.g. room 317). If you want to reach a specific room, you have to know both the address (so that you may find the hotel at all) and then the room number (because the hotel has several rooms).
Similarly, when a machine A on the Internet wants to talk to another machine B on the Internet, it tries to open a TCP connection to B on a specific port: the connection is marked with both the IP address of B, and a port number. Ports allow such a "B" machine to maintain several distinct services simultaneously: for instance, B will be both a Web server, expecting connections on port 80, and an email server, expecting connections on port 25. When some client opens a connection to B, B will know to which service the connection is targeted thanks to the port: if the connection is for port 80, it is Web; if it is for port 25, it is Email.
There are both Phyiscal and Virtual ports.
Physical network ports allow connecting cables to computers for instance:
There is also the concept of virtual ports,about which you are probably thinking. If found a nice tutorial here detailing the basic concepts of networking.
Ports are a concept, expressed as a number, that allow a service (program) on one computer to connect and exchange traffic with a particular service on another computer.
Many services conventionally use well defined port numbers, for example a web server would use and listen on port 80 for http traffic and port 443 for https traffic. Port numbers below 1024 are considered "special" in that a program requires elevated permissions to use them. Any port that a service is listening on is potentially vulnerable to attack if the service listening for traffic on the port is not designed with some care.
For example, the service may misbehave if receiving too many connections and/or traffic at a rate greater than it can handle. Services often expect traffic to conform to a restricted set of data, and may misbehave if sent data that they do not know how to handle. Flooding with traffic can result in a denial of service, where no further connections can be received, and potentially cause the machine to become unresponsive and require a reboot or power cycle.
Depending on what privileges the service enjoys, misbehaving may also mean that an attacker can perform operations on the computer that they should not be able to do, which could pose a security risk.
In an attempt at security, some services may be started to use non-conventional port numbers on the basis that a hacker would not immediately know what service was listening on the port, however as services often identify what they are when connected to, and others can be identified by behaviour when sent data, this is weak. Better security practice requires that access to ports is restricted only to those computers that need access to those services.