What is the difference between TCP and UDP, and what are common port numbers?
TCP is connection-oriented and reliable. It establishes a connection with a three-way handshake, numbers every segment, acknowledges receipt, retransmits what is lost, and delivers data in order. It also manages flow and congestion. The cost is overhead and latency.
UDP is connectionless. It sends datagrams with no handshake, no acknowledgement, no retransmission, and no ordering guarantee. It is faster and lighter, and the application must handle any loss itself.
How to choose: TCP where every byte must arrive — web pages, email, file transfer, database connections. UDP where timeliness beats completeness — live voice and video, gaming, and DNS, where a single small query and reply is cheaper than establishing a connection.
Common ports worth knowing:
- 20/21 FTP, 22 SSH and SFTP, 23 Telnet (insecure, should be disabled)
- 25 SMTP, 587 SMTP submission, 465 SMTPS
- 53 DNS (UDP normally, TCP for large responses and zone transfers)
- 67/68 DHCP, 69 TFTP
- 80 HTTP, 443 HTTPS
- 110 POP3, 143 IMAP, 993 IMAPS
- 389 LDAP, 636 LDAPS
- 3306 MySQL, 1433 SQL Server, 5432 PostgreSQL
- 3389 RDP, 445 SMB
Note: RDP and SMB should never be exposed directly to the internet — both are routinely scanned for and are common ransomware entry points.





