libcsdbg  1.28
C++ exception (and generic) stack trace debug library
tcpsockbuf & csdbg::tcpsockbuf::set_option ( i32  nm,
const void *  val,
u32  sz 
)
virtual

Set a socket option (applies only for the SOL_SOCKET ioctl level)

Parameters
[in]nmthe option name
[in]valthe new option value
[in]szthe sizeof val
Returns
*this
Exceptions
csdbg::exception
Attention
This method flushes the current buffer

Definition at line 265 of file tcpsockbuf.cpp.

References __D_ASSERT, flush(), csdbg::streambuf::m_handle, and unlikely.

266 {
267  __D_ASSERT(val != NULL);
268  __D_ASSERT(sz > 0);
269  if ( unlikely(val == NULL || sz == 0) )
270  return *this;
271 
272  /* Flush the buffer to avoid data loss or data corruption */
273  flush();
274 
275  i32 retval = setsockopt(m_handle, SOL_SOCKET, nm, val, sz);
276  if ( unlikely(retval < 0) )
277  throw exception(
278  "failed to set socket option %d (errno %d - %s)",
279  nm,
280  errno,
281  strerror(errno)
282  );
283 
284  return *this;
285 }
i32 m_handle
Stream handle (descriptor)
Definition: streambuf.hpp:43
int i32
32-bit signed integer
Definition: config.hpp:82
virtual tcpsockbuf & flush()
Flush the buffered data to the socket.
Definition: tcpsockbuf.cpp:220
#define unlikely(expr)
Offer a hint (negative) to the pipeline branch predictor.
Definition: config.hpp:349
#define __D_ASSERT(x)
Assertion macro.
Definition: config.hpp:268

+ Here is the call graph for this function: