-
-
Notifications
You must be signed in to change notification settings - Fork 722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
windows平台tb_socket_recv返回值问题 #154
Comments
关闭检测要走wait + recv 配合,才能跨平台通用 请参考 tbox/src/tbox/platform/socket.c Lines 194 to 221 in d27f280
|
目前tbox是不是不支持组播相关配置?
…------------------ 原始邮件 ------------------
发件人: "tboox/tbox" <notifications@github.com>;
发送时间: 2020年11月15日(星期天) 下午2:22
收件人: "tboox/tbox"<tbox@noreply.github.com>;
抄送: "449569708"<449569708@qq.com>;"Author"<author@noreply.github.com>;
主题: Re: [tboox/tbox] windows平台tb_socket_recv返回值问题 (#154)
关闭检测要走wait + recv 配合,才能跨平台通用
请参考
https://github.com/tboox/tbox/blob/d27f2807173dbc787582b6169e8e854a0ef396fc/src/tbox/platform/socket.c#L194-L221
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
是的 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
`tb_long_t tb_socket_recv(tb_socket_ref_t sock, tb_byte_t* data, tb_size_t size)
{
// check
tb_assert_and_check_return_val(sock && data, -1);
tb_check_return_val(size, 0);
#ifndef TB_CONFIG_MICRO_ENABLE
// attempt to use iocp object to recv data if exists
tb_iocp_object_ref_t iocp_object = tb_iocp_object_get_or_new_from_sock(sock, TB_POLLER_EVENT_RECV);
if (iocp_object) return tb_iocp_object_recv(iocp_object, data, size);
#endif
}`
问题描述:
在windows下,建立了tcp server和client,但是client正常关闭的时候,导致server无法判断client是否关闭。因为对于windows的recv函数,如果对端是正常关闭,返回值也为0(出自windows API原文:If no error occurs, recv returns the number of bytes received and the buffer pointed to by the buf parameter will contain this data received. If the connection has been gracefully closed, the return value is zero.),而现在这种情况 if (e == WSAEWOULDBLOCK || e == WSAEINPROGRESS) return 0; 也是返回0。
The text was updated successfully, but these errors were encountered: