|
|
|
date: Mon, 18 Feb 2008 14:11:46 +0100,
group: microsoft.public.platformsdk.networking
back
Sockets: setsockopt SO_SNDTIMEO does not set the send timeout.
Hi everybody!
I'm trying to set a 1 second "send timeout" to a SOCKET, using setsockopt.
Apparently it works, because the return value of setsockopt is non-zero.
BUT when I check the value of the "send timeout" via getsockopt, it's still
0, before and after calling setsockopt.
You can see code below.
Does anyone know what may be happening?
Thank you very much!
Best regards,
Ricardo Vázquez.
Madrid, Spain.
--CODE-----------------------
int nRet1 = -1;
int nLen1 = sizeof(nRet1);
if (getsockopt( m_listenSocket, IPPROTO_TCP, SO_SNDTIMEO, (char*)&nRet1,
(int*)&nLen1) != 0)
{
CString sLog;
sLog.Format("Send Timout = %d", nRet1);
g_logSystem.logNormal(0, sLog);
}
int nVal2 = 1000;
if (setsockopt( m_listenSocket, IPPROTO_TCP, setsockopt, (char*)&nVal2,
sizeof(nVal2)) == 0)
{
err.Format("[esvr] setsockopt(%ld SNDTIMEO) error: %ld",
m_listenSocket, WSAGetLastError());
g_logSystem.logWarning(0, err);
}
int nRet2 = -1;
int nLen2 = sizeof(nRet2);
if (getsockopt( m_listenSocket, IPPROTO_TCP, SO_SNDTIMEO, (char*)&nRet2,
(int*)&nLen2) != 0)
{
CString sLog;
sLog.Format("Send Timout = %d", nRet2); //-->HERE IT OUTPUTS 0,
/ /INSTEAD OF 1000!
g_logSystem.logNormal(0, sLog);
}
date: Mon, 18 Feb 2008 14:11:46 +0100
author: Ricardo Vazquez
Re: Sockets: setsockopt SO_SNDTIMEO does not set the send timeout.
"Ricardo Vazquez" wrote in message
news:u2V$o$icIHA.4144@TK2MSFTNGP05.phx.gbl
> I'm trying to set a 1 second "send timeout" to a SOCKET, using
> setsockopt. Apparently it works, because the return value of
> setsockopt is non-zero.
Quoting from documentation: "If no error occurs, setsockopt returns
*zero*. Otherwise, a value of SOCKET_ERROR is returned..." Emphasis
mine.
> int nRet1 = -1;
> int nLen1 = sizeof(nRet1);
> if (getsockopt( m_listenSocket, IPPROTO_TCP, SO_SNDTIMEO,
> (char*)&nRet1, (int*)&nLen1) != 0)
SO_SNDTIMEO is under SOL_SOCKET, not IPPROTO_TCP. Your getsockopt fails,
too.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
date: Mon, 18 Feb 2008 08:30:58 -0500
author: Igor Tandetnik
Re: Sockets: setsockopt SO_SNDTIMEO does not set the send timeout.
Heavens, Igor!
You were absolutely right.
Thank you very much for your quick, accurate and useful answer!
Best greetings,
Ricardo.
"Igor Tandetnik" escribió en el mensaje
news:%23L85CKjcIHA.6080@TK2MSFTNGP05.phx.gbl...
> "Ricardo Vazquez" wrote in message
> news:u2V$o$icIHA.4144@TK2MSFTNGP05.phx.gbl
>> I'm trying to set a 1 second "send timeout" to a SOCKET, using
>> setsockopt. Apparently it works, because the return value of
>> setsockopt is non-zero.
>
> Quoting from documentation: "If no error occurs, setsockopt returns
> *zero*. Otherwise, a value of SOCKET_ERROR is returned..." Emphasis mine.
>
>> int nRet1 = -1;
>> int nLen1 = sizeof(nRet1);
>> if (getsockopt( m_listenSocket, IPPROTO_TCP, SO_SNDTIMEO,
>> (char*)&nRet1, (int*)&nLen1) != 0)
>
> SO_SNDTIMEO is under SOL_SOCKET, not IPPROTO_TCP. Your getsockopt fails,
> too.
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
>
date: Mon, 18 Feb 2008 15:46:34 +0100
author: Ricardo Vazquez
|
|