recv function declaration:
int recv(SOCKET s, char FAR* buf, int len, int flags);
s[in] : the descriptor that identifies a connected socket.
buf[out] : a pointer to the buffer to receive the incoming data.
len[in] : the length , in bytes, of the buffer pointed to by the buf parameter.
flags[in] : a set of flags that influences the behavior of this function.
Following is sth about recv() function executing proess in SOCKET:
1. process A calls recv(), recv() function have to wait for DATA IN SEND BUF(发送缓冲) being transmited by protocol, if there are some errors in transmition about DATA IN SEND BUF, the function return SOCKET_ERROR.
2. after transmition about DISB, recv() checks RECV BUF(RB); if socket s[in]'s RB is empty or is receiving data, recv() has to block for a while.
3. after protocol receiving data, recv() copies data in RB to buf[in] (WARNING: data received by protocol may be larger than len[in], length of buf[in], if so, process has to call recv() for several times to copy data in RECV BUF. A IMPORT POINT is that : in fact recv() is just copying data from RB to some buffer, buf[in], and protocol, for example TCP/I&UDP, is the real receiver of data from netwrok part. )
4. the returning value of recv() is bytes number copied by the function recv(), if an error occurs in "recving", it returns SOCKET_ERROR, and it returns 0 while network is cutted down.
from: www.wenku.baidu.com
J.Yao 2011-5-14
int recv(SOCKET s, char FAR* buf, int len, int flags);
s[in] : the descriptor that identifies a connected socket.
buf[out] : a pointer to the buffer to receive the incoming data.
len[in] : the length , in bytes, of the buffer pointed to by the buf parameter.
flags[in] : a set of flags that influences the behavior of this function.
Following is sth about recv() function executing proess in SOCKET:
1. process A calls recv(), recv() function have to wait for DATA IN SEND BUF(发送缓冲) being transmited by protocol, if there are some errors in transmition about DATA IN SEND BUF, the function return SOCKET_ERROR.
2. after transmition about DISB, recv() checks RECV BUF(RB); if socket s[in]'s RB is empty or is receiving data, recv() has to block for a while.
3. after protocol receiving data, recv() copies data in RB to buf[in] (WARNING: data received by protocol may be larger than len[in], length of buf[in], if so, process has to call recv() for several times to copy data in RECV BUF. A IMPORT POINT is that : in fact recv() is just copying data from RB to some buffer, buf[in], and protocol, for example TCP/I&UDP, is the real receiver of data from netwrok part. )
4. the returning value of recv() is bytes number copied by the function recv(), if an error occurs in "recving", it returns SOCKET_ERROR, and it returns 0 while network is cutted down.
from: www.wenku.baidu.com
J.Yao 2011-5-14