g_tcp_socket(void)
{
#if defined(_WIN32)
  int rv;
  int option_value;
  int option_len;
#else
  int rv;
  int option_value;
  unsigned int option_len;
#endif

  /* in win32 a socket is an unsigned int, in linux, its an int */
  rv = (int)socket(PF_INET, SOCK_STREAM, 0);
  if (rv < 0)
  {
    return -1;
  }
  option_len = sizeof(option_value);
  if (getsockopt(rv, SOL_SOCKET, SO_REUSEADDR, (char*)&option_value,
                 &option_len) == 0)
  {
    if (option_value == 0)
    {
      option_value = 1;
      option_len = sizeof(option_value);
      setsockopt(rv, SOL_SOCKET, SO_REUSEADDR, (char*)&option_value,
                 option_len);
    }
  }
  option_len = sizeof(option_value);
  if (getsockopt(rv, SOL_SOCKET, SO_SNDBUF, (char*)&option_value,
                 &option_len) == 0)
  {
    if (option_value < (1024 * 32))
    {
      option_value = 1024 * 32;
      option_len = sizeof(option_value);
      setsockopt(rv, SOL_SOCKET, SO_SNDBUF, (char*)&option_value,
                 option_len);
    }
  }
  return rv;
}
g_tcp_socket(void)
{
#if defined(_WIN32)
  int rv;
  int option_value;
  int option_len;
#else
  int rv;
  int option_value;
  unsigned int option_len;
#endif

   
  rv = (int)socket(PF_INET, SOCK_STREAM, 0);
  if (rv < 0)
  {
    return -1;
  }
  option_len = sizeof(option_value);
  if (getsockopt(rv, SOL_SOCKET, SO_REUSEADDR, (char*)&option_value,
                 &option_len) == 0)
  {
    if (option_value == 0)
    {
      option_value = 1;
      option_len = sizeof(option_value);
      setsockopt(rv, SOL_SOCKET, SO_REUSEADDR, (char*)&option_value,
                 option_len);
    }
  }
  option_len = sizeof(option_value);
  if (getsockopt(rv, SOL_SOCKET, SO_SNDBUF, (char*)&option_value,
                 &option_len) == 0)
  {
    if (option_value < (1024 * 32))
    {
      option_value = 1024 * 32;
      option_len = sizeof(option_value);
      setsockopt(rv, SOL_SOCKET, SO_SNDBUF, (char*)&option_value,
                 option_len);
    }
  }
  return rv;
}