Click to See Complete Forum and Search --> : Visual C++ Network: How to set a socket option?


Andreas Masur
February 27th, 2003, 06:28 PM
Q: How to set a socket option?

A: Socket options can be set using the 'setsockopt()' function. The following shows the usage for the 'SO_REUSEADDR' option (others are set the same way).


int iOptval = 1;

if(::setsockopt(Socket, SOL_SOCKET, SO_REUSEADDR, (char *) &iOptval, sizeof(int)))
// Error -> call ::WSAGetLastError()

<br>