带有 RCVTIMEO 的 setsockopt() 在 windows mobile5 中不起作用 [英] setsockopt() with RCVTIMEO is not working in windows mobile5
问题描述
我正在尝试使用 setsockopt() API 和 so_rcvtimeo 选项设置对套接字描述符的 recieve() 调用超时,并将时间设置为 5 秒.但是当没有从服务器收到数据时,我的 recieve() 调用在 5 秒后没有超时.
I am trying to timeout the recieve() call on the socket descriptor, by using setsockopt() API with so_rcvtimeo option set with time set to 5 seconds. but my recieve() call is not timing out after 5 seconds when data is not recieved from server.
我可以知道是否需要在 Windows Mobile 5 中启用任何设置才能使其正常工作,或者是否有任何其他方法可以在 Windows Mobile 5/袖珍电脑中实现此目的
may i know if there is any settings to be enabled in windows mobile 5 to get this working or is there any other way to achieve this in windows mobile 5 / pocket pc
感谢和问候
推荐答案
setsocketopt
的 MSDN 文档清楚地说明(在备注部分):
The MSDN documentation for setsocketopt
clearly states (in the Remarks section):
以下列表显示了 setsockopt 不支持的 BSD 选项.
The following list shows BSD options that are not supported for setsockopt.
SO_ACCEPTCONN
SO_RCVLOWAT
SO_RCVTIMEO <--- 注意这个
SO_SNDLOWAT
SO_SNDTIMEO
SO_TYPE
SO_ACCEPTCONN
SO_RCVLOWAT
SO_RCVTIMEO <--- Note this one
SO_SNDLOWAT
SO_SNDTIMEO
SO_TYPE
解决方法"是在单独的线程上进行接收并在调用者中等待该线程,超时会中止生成的线程.
The "workaround" is to do the receive on a separate thread and wait on that thread in the caller, with a timeout that aborts the spawned thread.
这篇关于带有 RCVTIMEO 的 setsockopt() 在 windows mobile5 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!