COMPUTER NETWORKS/Student Engineering Notebook
Page 10·notes
TRANSPORT LAYER, TCP FLOW & CONGESTION CONTROL—~25 MIN READ

TCP Socket API: From socket() to accept()

GATE 2027 CS/IT core: TCP socket API; UDP appears only as a contrast

“Connect the transport service to the programming interface named in the GATE 2027 CS/IT syllabus.”

1.Prerequisites and endpoint model

Prerequisites: know that TCP provides a reliable ordered byte stream between endpoints and that a port identifies an application endpoint at a host. Review [TCP flow and congestion control](/notes/computer-networks/tcp-connection-and-congestion-control) if needed.

The socket API is the programming interface used by an application to ask the operating system for network communication. A server's usual passive-open sequence is socket → bind → listen → accept; a client's active-open sequence is socket → connect. After connection setup, both sides use send/recv (or equivalent operations) and close their endpoint when finished.

Each TCP connection is identified by its local and remote IP addresses and port numbers. accept() returns a new connected socket for one client; the original listening socket can continue accepting additional connections. A successful send may transmit fewer bytes than requested, and recv may return a partial application record, so application protocols need framing (for example, a fixed length or explicit length prefix).

UDP is a datagram service and can be contrasted with TCP, but it is not a named transport requirement in the current GATE 2027 CS/IT list. This note introduces only enough UDP semantics to distinguish socket types; it does not present UDP as GATE-core coverage.

WORKED NUMERICAL · STUDENT DERIVATION✎ Key Takeaway: Do not treat accept as converting the listening descriptor into the client connection.

Worked trace: two clients

Problem Statement:
A server calls listen(server_fd, ...), then accepts client A and client B. How many listening descriptors and connected descriptors exist after both accepts?
Step 1: Create the listener

server_fd remains the single listening descriptor.

Step 2: Accept client A

The first accept returns conn_A; server_fd remains open.

Step 3: Accept client B

The next accept returns conn_B; both connections coexist with server_fd.

Final Answer:One listening descriptor and two connected descriptors.
STUDENT PRACTICE · CONCEPT DRILL

Socket API checks

Problem 1 · FOUNDATION

Which call makes a TCP server socket passive and ready to queue incoming connection requests?

Problem 2 · GATE-LEVEL

After a successful accept(), which descriptor usually remains available for later clients?

RAPID REVIEW · NOTEBOOK SUMMARY

One-minute revision

core principle:

“Server: socket → bind → listen → accept. Client: socket → connect.”

must-remember principles:
  • •TCP connection endpoint pair = local (IP, port) + remote (IP, port)
  • •Listening socket ≠ accepted connected socket
critical exam pitfalls:
  • •accept returns a new descriptor
  • •TCP is a byte stream, not a message protocol
  • •send/recv may be partial
  • •UDP is comparative enrichment here
SOURCE TRANSPARENCY & CITATIONS

Primary Academic References & Exam Sources

Every concept in Notes From a B.Tech Brain is synthesized from authoritative academic texts, seminal peer-reviewed research, verified exam archives, and renowned university lectures.

Primary Academic Texts
The Linux Programming Interface↗by · Socket API system calls, client/server sequence, and stream semantics.
ACADEMIC STANDARD
Official Examination Archives
GATE 2027 CS/IT syllabus↗IIT Madras · Computer Networks: TCP flow/congestion control and socket API.
GATE CS OFFICIAL
RECOMMENDED YOUTUBE EDUCATORS & FULL-COURSE PLAYLISTS

Curated for clarity, rigorous numerical solving, and semester excellence:

Knowledge Gate · Computer Networks for GATE↗Instructor: Sanchit Jain · Covers: OSI/TCP-IP layers, sliding window, CRC, subnetting, TCP congestion control

GATE-level numerical drilling and PYQ analysis.

Open YouTube↗
Gate Smashers · Computer Networks Full Course↗Instructor: Varun Singla · Covers: Ethernet, IP addressing, routing algorithms, TCP/UDP, DNS & HTTP

Step-by-step conceptual walkthroughs with worked GATE numericals.

Open YouTube↗
Neso Academy · Computer Networks Series↗Instructor: Neso Academy · Covers: Data link layer, framing, error detection, medium access, TCP/IP

Clear whiteboard lectures for foundational and semester exam coverage.

Open YouTube↗