From Beej’s socket programming book:
When Unix programs do any sort of I/O, they do it by reading or
writing to a file descriptor. A file descriptor is simply an integer
associated with an open file.
Does it say that programs read and “write” to a “integer”? If yes, how is it possible and what does it mean?
It’s saying that file descriptors are implemented as an integer. That is each open file is given a unique way of referencing it, a file handle which is actually just a unique number.
When you do:
fdis an integer, which is returned by the implementation. It’s unique to the file you opened within your program and given to you so that later you can refer to that same file, e.g. forread/write/closeetc. It’s nothing more than a token used to associate a sequence of operations.