How to set the keep alive interval for winsock

后端 未结 2 518
失恋的感觉
失恋的感觉 2021-02-08 02:48

I am using winsock and TCP. I have set the KeepAlive option as follows

int aliveToggle = 1;
setsockopt(mySocket,SOL_SOCKET,SO_KEEPALIVE,(char*)&         


        
2条回答
  •  情深已故
    2021-02-08 03:26

    From c/c++ you should be able to use SIO_KEEPALIVE_VALS to control the timeouts. You can't use setsockopt, but you should be able to use WSAIoctl. See http://msdn.microsoft.com/en-us/library/windows/desktop/dd877220%28v=vs.85%29.aspx

    Here's an example http://read.pudn.com/downloads79/ebook/301417/Chapter09/SIO_KEEPALIVE_VALS/alive.c__.htm

提交回复
热议问题