Set timeout for winsock recvfrom

后端 未结 4 1591
野性不改
野性不改 2020-12-05 19:13

I\'m trying to set up a blocking socket to timeout after 16 ms of trying to recvfrom() on a port. Platform is Windows. I\'ve looked at tons of examples online and it seems

4条回答
  •  温柔的废话
    2020-12-05 19:48

    I tried it by passing it like the folloing

         int iTimeout = 1600;
         iRet = setsockopt( pSapManager->m_cSocket,
                            SOL_SOCKET,
                            SO_RCVTIMEO,
                            /*
                            reinterpret_cast(&tv),
                            sizeof(timeval) );
                            */
                            (const char *)&iTimeout,
                            sizeof(iTimeout) );
    

    and run it!!

提交回复
热议问题