What does `return 0(or -1`) mean when i write(or read) socket in C on linux?

And Under what circumstances will these things happen?

and how to deal with `errno==EINTR`?

using `write() and read()` functions.