read system call

When i read 4 bytes from a socket the read function returns 0 value. what does it mean?
How should i know whether a message is available in the socket or not?

>When i read 4 bytes from a socket the read function returns 0 value. what does it mean?
Read man pages on read(), the return value section. The return value of read() would be zero, stressing there were no bytes read on that stream.

>How should i know whether a message is available in the socket or not?
You could use select() or poll(), the choice is yours.