0

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

Sal
  • 11
  • 1
  • 6
  • ?If the socket is created using the WSASocket function, then the dwFlags parameter must have the WSA_FLAG_OVERLAPPED attribute set for the timeout to function properly. Otherwise the timeout never takes effect. – EricLaw Aug 13 '11 at 13:39
  • Also, see http://social.msdn.microsoft.com/forums/en-US/vssmartdevicesnative/thread/65f6c563-07fa-4e36-8b71-438a15b942a9/ – EricLaw Aug 13 '11 at 13:40
  • Eric,socket is created using normal socket() function – Sal Aug 13 '11 at 13:45
  • the discussion forums specified by you indicates that rcvtimeout is not implemented in windows mobile 5 – Sal Aug 13 '11 at 13:52

1 Answers1

0

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.

Community
  • 1
  • 1
ctacke
  • 66,480
  • 18
  • 94
  • 155
  • But is there any way to achieve this recieve time out without multi threaded programming ?? i got sequential processing of the calls – Sal Aug 13 '11 at 18:04
  • Not without multi-threading, no. You can still fake synchronous behavior by having the thread signal an event that the caller waits on. – ctacke Aug 13 '11 at 18:59