What does ssize_t read(int fd, void * data, size_t count); exactly do?
In a lot of articles in the web is often written, that it tries to read from or the descriptor fd. What does that mean? “It tries” :/ And how is such a socket designed? Does the OS buffer the messages coming in? Or is a read a time critical operation? I mean is there the posibility that some packages get lost, if i dont “read” in time?
EDIT:
I wondered a while now why this is not blocking. Then I wondered why read(…) has other parameters than all functions I saw in code snippets. Finally I realized that it is read(…) not recv(…). Unlucky that it still worked nearly as i expected. And fnuny how our ascostaivie tohuhgts paly geams wtih us. (Don’t edit) I have to admit that the example german has more effect on the reader…
Linux will buffer any data which arrives on a connected TCP socket, up to a few megabytes by default. You dont have to read at the exact same time the data arrives.
netstat -tnwill showRecv-QandSend-Qfor each connected socket, which is the number of bytes queued in each direction.