Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Course Introduction: Programming the Network, Not Just Studying It

Lesson 1 of 15 in the free Network Programming notes on Siksha Sarovar, written by Rohit Jangra.

Welcome to Network Programming

Computer Networks taught you how the Internet works — layers, protocols, headers. Network Programming teaches you to write the programs at both ends of the wire: clients, servers, daemons, ping, traceroute, even packet sniffers. The toolkit is the sockets API — the C interface (born in 4.2BSD UNIX, 1983) that still underlies every networked program: browsers, game servers, Node.js, Python's socket module, all of them.

The guiding textbook tradition for this paper is W. Richard Stevens' UNIX Network Programming — the lessons follow its path and its famous client/server examples.

The journey of this course

How this course is organised

Syllabus blockLessons that cover it
OSI model, Unix standards, TCP/UDP, connection establishment, buffer sizes, standard servicesUnit 1 → "Protocol Foundations"
Socket address structures, value-result arguments, byte orderingUnit 1 → "Socket Address Structures & Byte Ordering"
socket, connect, bind, listen, accept, fork/exec, concurrent servers, closeUnit 1 → "Elementary TCP Sockets"
TCP echo client/server, signal handling, server crash/reboot scenariosUnit 2 → "The TCP Echo Client–Server & Its Failure Modes"
Elementary UDP sockets, lost datagrams, no flow control, outgoing interfaceUnit 2 → "Elementary UDP Sockets"
I/O models, select, poll, shutdown, batch inputUnit 2 → "I/O Multiplexing"
getsockopt/setsockopt, socket states, all option levelsUnit 2 → "Socket Options & Advanced I/O" (first half)
Socket timeouts, recv/send flags, readv/writev, recvmsg/sendmsg, ancillary dataUnit 2 → "Socket Options & Advanced I/O" (second half)
DNS, gethostbyname, resolver, IPv6 functions, unameUnit 3 → "Name & Address Conversions"
Daemons, syslog, daemon_init, inetdUnit 3 → "Daemon Processes & the inetd Superserver"
Broadcasting, unicast vs broadcast, race conditionsUnit 3 → "Broadcasting"
Multicasting, mcast_join, MBone, SNTPUnit 3 → "Multicasting & SNTP"
Raw sockets, ping, traceroute, ICMP daemonUnit 4 → "Raw Sockets"
BPF, DLPI, SOCK_PACKET, libpcap, UDP checksumUnit 4 → "Datalink Access"
Terminal line disciplines, pseudo-terminals, rlogin, RPC transparencyUnit 4 → "Remote Login & RPC Transparency"
Lab programs (sockets in C)"Lab Practicals" lesson at the end

Prerequisites

You should knowWhy
C programming (pointers, structs, fork)the entire API is C
TCP/IP basics: IP addresses, ports, the 3-way handshakewe now drive these from code
Basic Unix/Linux shellcompiling, running client+server in two terminals

How to study this course

  1. Type and run every program. A Linux machine (or WSL on Windows) and gcc are all you need. One run of an echo server teaches more than three readings.
  2. Keep two terminals open — client on the left, server on the right — and watch both sides of every experiment.
  3. Use the tools as you learn the calls: netstat -an / ss -tan to see socket states, tcpdump/Wireshark to watch the segments your code generates.
  4. Draw the call sequence for every program — the socket-function "ladder diagrams" in these lessons are the exact diagrams exam answers want.
  5. Memorise the failure-mode stories (Unit 2): what the client sees when the server crashes, vs reboots, vs is unreachable — favourite viva and theory questions.

What end-term questions in this paper look like

Network Programming questions come in four recognisable shapes — knowing the shape tells you how to structure the answer:

Question shapeExampleWhat a full-marks answer contains
"Explain function X""Explain accept() with its arguments"full prototype, each argument's role and direction, return value, one error case, 3–4 line code fragment
"Diagram + walkthrough""Explain TCP connection establishment"the sequence/ladder diagram, segment names (SYN, SYN-ACK, ACK), which socket call blocks where, state names
"Compare A and B""Compare select and poll" / "TCP vs UDP"a table of 5–7 rows, then 2–3 sentences saying when you'd choose which
"Scenario / what happens if""What does the client observe when the server host crashes?"timeline of events on the wire, the errno the application finally sees, and the fix (timeout / keep-alive / select)

Two writing habits that consistently earn marks: always give the prototype before discussing a function (examiners scan for it), and always name the errno in failure scenarios — "the call fails" earns half of what "connect returns −1 with errno ECONNREFUSED because an RST arrived" earns.

The vocabulary you must own before Unit 1

A quick glossary — every term below is defined properly in its lesson, but you should recognise them from day one:

  • descriptor (fd): small integer naming an open file/socket in a process — the currency of the whole API.
  • segment / datagram / frame: the protocol unit at TCP / UDP-IP / link layer respectively. Using the right word signals competence.
  • well-known vs ephemeral port: server's fixed advertised port vs the kernel-chosen temporary client port.
  • blocking call: one that puts the process to sleep until the event happens (default for accept, read, recvfrom...).
  • half-close: closing one direction of a TCP connection while the other keeps flowing (shutdown).
  • RST vs FIN: abortive reset vs orderly goodbye — the difference drives half of Unit 2's failure stories.

Self-check before you begin

  1. Which layer of the OSI model does the sockets API expose to your program, and which layers does your program itself implement?
  2. Name the three pieces of information that uniquely identify one end of a TCP connection, and the four that identify the whole connection.
  3. Why does a TCP application need two terminals (client + server) to test, while a UDP experiment can sometimes fake it with one?
  4. What tool shows you the TCP state (LISTEN, ESTABLISHED...) of every socket on your machine right now?

If question 2 made you pause — (IP, port) per end; (client IP, client port, server IP, server port) for the connection, the famous 4-tuple — you are exactly where this course expects you to start.