Make get/setsockopt handle SOREUSEADDR

This commit is contained in:
Erik van der Kouwe 2010-01-07 09:53:08 +00:00
parent 413a8083b9
commit 1a39ed880a
2 changed files with 24 additions and 0 deletions

View file

@ -78,6 +78,12 @@ static int _tcp_getsockopt(int socket, int level, int option_name,
{
int i, r, err;
if (level == SOL_SOCKET && option_name == SO_REUSEADDR)
{
i = 1; /* Binds to TIME_WAIT sockets never cause errors */
getsockopt_copy(&i, sizeof(i), option_value, option_len);
return 0;
}
if (level == SOL_SOCKET && option_name == SO_KEEPALIVE)
{
i = 1; /* Keepalive is always on */

View file

@ -63,6 +63,24 @@ static int _tcp_setsockopt(int socket, int level, int option_name,
{
int i;
if (level == SOL_SOCKET && option_name == SO_REUSEADDR)
{
if (option_len != sizeof(i))
{
errno= EINVAL;
return -1;
}
i= *(int *)option_value;
if (!i)
{
/* At the moment there is no way to turn off
* reusing addresses.
*/
errno= ENOSYS;
return -1;
}
return 0;
}
if (level == SOL_SOCKET && option_name == SO_KEEPALIVE)
{
if (option_len != sizeof(i))