---
title: "Socket and its importance"
subject: "Computer Networks and Security"
chapter: 5
key: "semester_7/computer_networks_and_security:socket-importance"
source: https://www.bctengineer.com/q/semester_7/computer_networks_and_security/socket-importance
site: BCT Engineering
---

# Socket and its importance

Computer Networks and Security · Chapter 5: Transport Layer

- Asked in: 2074 Asoj, 3 marks
- Video: [What is socket | How socket works | Types of Sockets | Socket Address | TCP Socket | UDP Socket](https://www.youtube.com/watch?v=-utm73RxNo4) — Chirag Bhalodia
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/computer_networks_and_security/socket-importance
- Whole chapter: https://www.bctengineer.com/md/semester_7/computer_networks_and_security/chapter-5

## Question

What do you understand by socket? Explain its importance.

## Short answer

A socket is an endpoint for network communication, identified by IP address and port. It provides the API between applications and transport layer, enables multiple concurrent connections, hides TCP/IP details, and supports client-server and peer-to-peer applications.

## Answer

A **socket** is an endpoint of a two-way communication link between two programs running on the network. It is identified by an **IP address + port number** (e.g. 192.168.1.5:80) and a protocol (TCP or UDP). A connection is identified uniquely by the pair of sockets (source IP, source port, destination IP, destination port).

#### Types
- **Stream socket (SOCK_STREAM):** uses TCP; reliable, connection-oriented.
- **Datagram socket (SOCK_DGRAM):** uses UDP; connectionless.

#### Importance
1. It is the **interface (API) between the application and the transport layer**; programs use calls like `socket()`, `bind()`, `listen()`, `accept()`, `connect()`, `send()`, `recv()`, `close()`.
2. It lets many applications on the same host communicate at the same time through different port numbers.
3. It hides the details of TCP/IP, so programmers do not manage packets directly.
4. It enables client-server and peer-to-peer applications such as web, email and chat.
5. It is portable across operating systems (Berkeley sockets, Winsock).

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What identifies a socket?
   A. Hostname only
   B. MAC address only
   C. IP address + port number (and protocol)
   D. Routing table entry
   Answer: C. A socket is an IP:port endpoint with a protocol. (Key point: Socket identity)

2. Which socket type uses TCP?
   A. SOCK_DGRAM
   B. SOCK_RAW only
   C. SOCK_STREAM
   D. Datagram socket
   Answer: C. Stream sockets are reliable, connection-oriented TCP; datagram sockets use UDP. (Key point: Socket types)

3. Why are sockets important?
   A. They assign IP addresses
   B. They encrypt traffic
   C. They are the API between application and transport layer, letting many applications communicate via ports
   D. They route packets
   Answer: C. Sockets hide TCP/IP details and allow multiple apps on one host. (Key point: Importance)

## Related in Computer Networks and Security

- [Media Access Control and significance](https://www.bctengineer.com/question.md?key=semester_7%2Fcomputer_networks_and_security%3Amac-significance) — Computer Networks and Security, chapter 3

## Related in other subjects

- [Approximate estimate: what and when](https://www.bctengineer.com/question.md?key=semester_7%2Festimating_and_costing%3Aapproximate-estimate-when-needed) — Estimating and Costing, chapter 3, asked 6×
- [Infinite effective mass and its E-k explanation](https://www.bctengineer.com/question.md?key=semester_3%2Felectrical_engineering_material%3Ainfinite-effective-mass-ek) — Electrical Engineering Material, chapter 1, asked 4×
- [Method of characteristics; FD form for pipe flow](https://www.bctengineer.com/question.md?key=semester_8%2Fcomputational_techniques_in_civil_engineering%3Amoc-definition-fd-pipe-equations) — Computational Techniques in Civil Engineering, chapter 6, asked 4×
- [Profession and its characteristics](https://www.bctengineer.com/question.md?key=semester_8%2Fengineering_professional_practice%3Aprofession-characteristics) — Engineering Professional Practice, chapter 2, asked 3×
