What is the Difference Between read() and recv() , and Between send() and write()?
The difference is that recv()
/send()
work only on socket descriptors and let you specify certain options for the actual operation. Those functions are slightly more specialized (for instance, you can set a flag to ignore SIGPIPE
, or to send out-of-band messages...).
Functions read()
/write()
are the universal file descriptor functions working on all descriptors.
Per the first hit on Google
read() is equivalent to recv() with a flags parameter of 0. Other values for the flags parameter change the behaviour of recv(). Similarly, write() is equivalent to send() with flags == 0.
read()
and write()
are more generic, they work with any file descriptor.
However, they won't work on Windows.
You can pass additional options to send()
and recv()
, so you may have to used them in some cases.