- 论坛徽章:
- 0
|
第二种双线程的方式已经是一种不错的模型了,在实际中应用也不少,上面量段文字和图片说明了服务端和客户端 ...
duanjigang 发表于 2011-01-02 11:39 ![]()
man recv
If no messages are available at the socket, the receive calls wait for
a message to arrive, unless the socket is nonblocking (see fcntl(2)),
in which case the value -1 is returned and the external variable errno
is set to EAGAIN or EWOULDBLOCK. The receive calls normally return any
data available, up to the requested amount, rather than waiting for
receipt of the full amount requested.
RETURN VALUE
These calls return the number of bytes received, or -1 if an error
occurred. The return value will be 0 when the peer has performed an
orderly shutdown.
ERRORS
These are some standard errors generated by the socket layer. Addi鈥
tional errors may be generated and returned from the underlying proto鈥
col modules; see their manual pages.
EAGAIN or EWOULDBLOCK
The socket is marked nonblocking and the receive operation would
block, or a receive timeout had been set and the timeout expired
before data was received. POSIX.1-2001 allows either error to
be returned for this case, and does not require these constants
to have the same value, so a portable application should check
for both possibilities. |
|