Port scanning with Nmap works by sending small probe packets to specific ports on a target computer. Nmap waits for replies to see if the ports respond with SYN-ACK (open), RST (closed), or no response (filtered). For example, sending a SYN packet to port 22 and receiving SYN-ACK means the port is open. If no response comes from port 80, it is filtered (e.g., by a firewall). Receiving RST from port 443 means it is closed. This scanning method is called a TCP SYN scan and is stealthy because it does not complete the full connection. The scan ends after checking all target ports and then shows a summary of which ports are open, closed, or filtered. This helps users understand what services are running on the target and find security weaknesses.