TRT
Sign in

Core · Module 5 · Lesson 3 of 12

Unbuffered I/O: read, write, and Partial Transfers

Master low-level POSIX read and write system calls, construct robust partial transfer loops, and handle signal interrupts and EOF conditions.

Pro — members onlyAbout 16 minutes

By the end you can

  • Differentiate ssize_t return values across success, EOF, and error conditions
  • Construct production-grade read_all and write_all loops that handle partial transfers
  • Handle transient system call interruptions by checking errno for EINTR
  • Contrast unbuffered kernel system call overhead with user-space buffer sizing

Builds on File Descriptors and Kernel File Tables.

01 · A question first

Why does assuming write(fd, buf, 1024) writes all 1,024 bytes work reliably on local SSD files, yet silently corrupts data as soon as the code runs over a pipe or TCP socket? The answer lies in how POSIX defines partial byte transfers across kernel boundaries.

Make a guess before you read on.

02 · The idea

Members only

Unlock the full lesson

This lesson is part of the membership. Join to read it in full, along with every other premium deep dive.

What's inside

  • Start with the problem
  • How the idea works
  • Why it is correct
  • What it costs
  • Pitfalls and variations
  • Where it is used

03 · Practice

Something wrong with this lesson? Report a problem