setsockopt() with RCVTIMEO is not working in windows mobile5

夙愿已清 提交于 2019-12-25 00:29:45

问题


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.

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

Thanks and regards


回答1:


The MSDN documentation for setsocketopt clearly states (in the Remarks section):

The following list shows BSD options that are not supported for setsockopt.

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.



来源:https://stackoverflow.com/questions/7050594/setsockopt-with-rcvtimeo-is-not-working-in-windows-mobile5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!