Skip to main content

Handling files in Unix

Readโ€‹

The return value can be:

  • -1: error
  • 0: EOF
  • n: n bytes of data in the first n bytes of the buffer

Writeโ€‹

The return value can be:

  • -1: error
  • 0: write again with a new message
  • n: n bytes of data in the first n bytes of the buffer are consumed by OS