|
reSIProcate/rutil
9694
|
#include <cassert>#include <fcntl.h>#include <errno.h>#include "rutil/compat.hxx"#include "rutil/Socket.hxx"#include "rutil/Logger.hxx"#include <unistd.h>#include <sys/resource.h>
Go to the source code of this file.
Defines | |
| #define | RESIPROCATE_SUBSYSTEM Subsystem::TRANSPORT |
Functions | |
| static int | trySetRcvBuf (Socket fd, int buflen) |
| Some OSs (Linux in particular) silently ignore requests to set too big and do not return an error code. | |
| #define RESIPROCATE_SUBSYSTEM Subsystem::TRANSPORT |
Definition at line 18 of file Socket.cxx.
| static int trySetRcvBuf | ( | Socket | fd, |
| int | buflen | ||
| ) | [static] |
Some OSs (Linux in particular) silently ignore requests to set too big and do not return an error code.
Thus we always check. Also, the returned value (getsockopt) can be larger than the requested value (kernel internally doubles). manpage says sockopt uses integer as data-type If {buflen} is negative, we skip the set and just read Return the get size or -1 if the set didn't work
Definition at line 198 of file Socket.cxx.
Referenced by resip::setSocketRcvBufLen().
{
if (buflen > 0)
{
int wbuflen = buflen;
#if !defined(WIN32)
if (::setsockopt (fd, SOL_SOCKET, SO_RCVBUF, &wbuflen, sizeof(wbuflen)) == -1)
#else
if (::setsockopt (fd, SOL_SOCKET, SO_RCVBUF, (const char*)&wbuflen, sizeof(wbuflen)) == -1)
#endif
{
return -1;
}
}
int rbuflen = 0;
unsigned optlen = sizeof(rbuflen);
if (getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&rbuflen, (socklen_t *)&optlen) == -1)
{
return -1;
}
assert(optlen == sizeof(rbuflen));
if (rbuflen < buflen)
{
return -1;
}
return rbuflen;
}
1.7.5.1