Пример #1
0
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// \brief 생성자
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CAsyncTcpSendEvent::CAsyncTcpSendEvent(int maxCount)
:
m_WsaBufArray(nullptr),
m_CurrentCount(0),
m_MaxCount(maxCount),
m_TotalBytes(0),
m_SendArray()
{
	SafeGuard();

	m_WsaBufArray = xnew_array(WSABUF, maxCount);
	for (int i = 0; i < maxCount; ++i)
	{
		m_SendArray[i] = nullptr;
	}
}
Пример #2
0
Файл: host.c Проект: Red54/axtu
static struct address_list *
address_list_from_addrinfo (const struct addrinfo *ai)
{
  struct address_list *al;
  const struct addrinfo *ptr;
  int cnt;
  ip_address *ip;

  cnt = 0;
  for (ptr = ai; ptr != NULL ; ptr = ptr->ai_next)
    if (ptr->ai_family == AF_INET || ptr->ai_family == AF_INET6)
      ++cnt;
  if (cnt == 0)
    return NULL;

  al = xnew0 (struct address_list);
  al->addresses = xnew_array (ip_address, cnt);
  al->count     = cnt;
  al->refcount  = 1;

  ip = al->addresses;
  for (ptr = ai; ptr != NULL; ptr = ptr->ai_next)
    if (ptr->ai_family == AF_INET6) 
      {
	const struct sockaddr_in6 *sin6 =
	  (const struct sockaddr_in6 *)ptr->ai_addr;
	ip->type = IPV6_ADDRESS;
	ADDRESS_IPV6_IN6_ADDR (ip) = sin6->sin6_addr;
#ifdef HAVE_SOCKADDR_IN6_SCOPE_ID
	ADDRESS_IPV6_SCOPE (ip) = sin6->sin6_scope_id;
#endif
	++ip;
      } 
    else if (ptr->ai_family == AF_INET)
      {
	const struct sockaddr_in *sin =
	  (const struct sockaddr_in *)ptr->ai_addr;
	ip->type = IPV4_ADDRESS;
	ADDRESS_IPV4_IN_ADDR (ip) = sin->sin_addr;
	++ip;
      }
  assert (ip - al->addresses == cnt);
  return al;
}
Пример #3
0
Файл: host.c Проект: Red54/axtu
static struct address_list *
address_list_from_ipv4_addresses (char **vec)
{
  int count, i;
  struct address_list *al = xnew0 (struct address_list);

  count = 0;
  while (vec[count])
    ++count;
  assert (count > 0);

  al->addresses = xnew_array (ip_address, count);
  al->count     = count;
  al->refcount  = 1;

  for (i = 0; i < count; i++)
    {
      ip_address *ip = &al->addresses[i];
      ip->type = IPV4_ADDRESS;
      memcpy (ADDRESS_IPV4_DATA (ip), vec[i], 4);
    }

  return al;
}
Пример #4
0
static struct address_list *
address_list_from_hostent (struct hostent *host)
{
  int count, i;
  struct address_list *al = xnew0 (struct address_list);

  for (count = 0; host->h_addr_list[count]; count++)
    ;

  assert (count > 0);

  al->addresses = xnew_array (ip_address, count);
  al->count     = count;
  al->refcount  = 1;

  for (i = 0; i < count; i++)
    {
      ip_address *ip = &al->addresses[i];
      ip->family = host->h_addrtype;
      memcpy (IP_INADDR_DATA (ip), host->h_addr_list[i], ip->family == AF_INET ? 4 : 16);
    }

  return al;
}