Re: [asio-users] How to set TCP/IP socket keep-alive options...
Brought to you by:
chris_kohlhoff
From: James T. <Jam...@om...> - 2009-01-28 08:39:29
|
Emilio, Not detracting from Nicolas Alvarez' comments at all, but if you want to side-step asio you can always do so using the native() function to get the native socket HANDLE. Then call WSAIoctl as per your example. Jim ________________________________ From: Emilio Pombo [mailto:ep...@in...] Sent: Tue 27/01/2009 16:57 To: A: Lista Asio Subject: [asio-users] How to set TCP/IP socket keep-alive options... Hi guys, I'm a C++ programmer using Boost Asio from some month ago. I want to know if there is any way to set TCP/IP protocol keep-alive options on an Asio socket abstraction? I enabled keep-alive property, as the web example shows easy with something like: ... asio::socket_base::keep_alive keepAlive(true); m_socket.set_option(keepAlive); ... But the default -in my case native implementation is WinSock, I'm on win32- keep-alive time is too big for my aplication requeriments. When I mentioned "keep-alive options" I refer to keep-alive time, interval, etc, ie. on a WinSock native implemtation should I think it could be donne by something like: ... int iRet = setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (char*)&bOptVal, bOptLen); if(iRet == SOCKET_ERROR) { return WSAGetLastError(); } DWORD dwBytes = 0; tcp_keepalive kaSettings= {0}, sReturned = {0} ; kaSettings.onoff = 1 ; kaSettings.keepalivetime = m_keepAliveTime; // Keep Alive in n sec. kaSettings.keepaliveinterval = m_keepAliveInterval; // Resend if No-Reply if (WSAIoctl(sock, SIO_KEEPALIVE_VALS, &kaSettings, sizeof(kaSettings), &sReturned, sizeof(sReturned), &dwBytes, NULL, NULL) != 0) { return WSAGetLastError(); } ... Thanks a lot, regards. Emilio Pombo Development Team ep...@in... Tel: +598 2 400-7885 www.inConcertCC.com <http://www.inconcertcc.com/> ________________________________________________________________________ This e-mail, and any attachment, is confidential. If you have received it in error, do not use or disclose the information in any way, notify me immediately, and please delete it from your system. ________________________________________________________________________ |