本文整理汇总了C++中ACE_INET_Addr::get_size方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_INET_Addr::get_size方法的具体用法?C++ ACE_INET_Addr::get_size怎么用?C++ ACE_INET_Addr::get_size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_INET_Addr
的用法示例。
在下文中一共展示了ACE_INET_Addr::get_size方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
ACE_INET_Addr::ACE_INET_Addr (const ACE_INET_Addr &sa)
: ACE_Addr (sa.get_type (), sa.get_size())
{
ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr");
this->reset ();
this->set (sa);
}
示例2: sizeof
int
ACE_INET_Addr::set (const ACE_INET_Addr &sa)
{
ACE_TRACE ("ACE_INET_Addr::set");
if (sa.get_type () == AF_ANY)
// Ugh, this is really a base class, so don't copy it.
ACE_OS::memset (&this->inet_addr_, 0, sizeof (this->inet_addr_));
else
{
// It's ok to make the copy.
ACE_OS::memcpy (&this->inet_addr_,
&sa.inet_addr_,
sa.get_size ());
this->set_type (sa.get_type());
this->set_size (sa.get_size());
}
return 0;
}
示例3: return
bool
ACE_INET_Addr::operator == (const ACE_INET_Addr &sap) const
{
ACE_TRACE ("ACE_INET_Addr::operator ==");
if (this->get_type () != sap.get_type ()
|| this->get_size () != sap.get_size ())
return false;
return (ACE_OS::memcmp (&this->inet_addr_,
&sap.inet_addr_,
this->get_size ()) == 0);
}
示例4: defined
bool
ACE_INET_Addr::is_ip_equal (const ACE_INET_Addr &sap) const
{
if (this->get_type () != sap.get_type ()
|| this->get_size () != sap.get_size ())
return false;
#if defined (ACE_HAS_IPV6)
if (this->get_type () == PF_INET6)
{
const unsigned int *addr =
reinterpret_cast<const unsigned int*>(this->ip_addr_pointer());
const unsigned int *saddr =
reinterpret_cast<const unsigned int*>(sap.ip_addr_pointer());
return (addr[0] == saddr[0] &&
addr[1] == saddr[1] &&
addr[2] == saddr[2] &&
addr[3] == saddr[3]);
}
else
#endif /* ACE_HAS_IPV6 */
return this->get_ip_address () == sap.get_ip_address();
}
示例5: sizeof
int
ACE_Ping_Socket::send_echo_check (ACE_INET_Addr &remote_addr,
bool to_connect)
{
if (this->get_handle () == ACE_INVALID_HANDLE)
{
errno = EBADF;
return -1;
}
sockaddr_in *addr_connect = 0;
addr_connect = (sockaddr_in *) remote_addr.get_addr ();
/*
* Nulling port field to prevent strange behavior, when a raw
* socket is "connected" to a sockaddr_in with a non-nulled port.
*/
ACE_OS::memset ((void*) &addr_connect->sin_port,
0,
sizeof (addr_connect->sin_port));
// to connect the socket
if (to_connect && !this->connected_socket_)
{
if (ACE_OS::connect (this->get_handle (),
(sockaddr*) addr_connect,
remote_addr.get_size ()) == -1)
{
if (errno != EINTR)
return -1;
}
this->connected_socket_ = true;
}
ACE_OS::memset (this->icmp_send_buff_, 0, sizeof this->icmp_send_buff_);
int datalen = ICMP_DATA_LENGTH;
struct icmp *_icmp = 0;
_icmp = (struct icmp *) this->icmp_send_buff_;
_icmp->icmp_type = ICMP_ECHO;
_icmp->icmp_code = 0;
_icmp->icmp_id = ACE_OS::getpid () & 0xFFFF;
_icmp->icmp_seq = sequence_number_++;
#if defined (ACE_WIN32)
_icmp->icmp_data = GetTickCount ();
#else /* #if defined (ACE_WIN32) */
gettimeofday ((struct timeval *) &_icmp->icmp_data, 0);
#endif /* #if defined (ACE_WIN32) */
int length_icmp = ICMP_MIN + datalen; // checksum ICMP header and data.
_icmp->icmp_cksum = 0;
_icmp->icmp_cksum = inherited::calculate_checksum ((u_short *) _icmp,
length_icmp);
int rval_send = -1;
if ((rval_send = send ((void const *) icmp_send_buff_,
length_icmp,
remote_addr)) != length_icmp)
{
return -1;
}
return 0;
}
示例6: sizeof
int
ACE::Ping_Socket::send_echo_check (ACE_INET_Addr &remote_addr,
int to_connect)
{
if (this->get_handle () == ACE_INVALID_HANDLE)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) ACE::Ping_Socket::make_echo_check - "
"invalid descriptor."),
-1);
}
sockaddr_in *addr_connect = NULL;
addr_connect = (sockaddr_in *) remote_addr.get_addr ();
/*
* Nulling port field to prevent strange behavior, when a raw
* socket is "connected" to a sockaddr_in with a non-nulled port.
*/
ACE_OS::memset ((void*) &addr_connect->sin_port,
0,
sizeof (addr_connect->sin_port));
// to connect the socket
if (to_connect && !this->connected_socket_)
{
if (ACE_OS::connect (this->get_handle (),
(sockaddr*) addr_connect,
remote_addr.get_size ()) == -1)
{
if (errno != EINTR)
{
ACE_ERROR_RETURN ((LM_ERROR,
"%p\n", "(%P|%t) "
"ACE::Ping_Socket::make_echo_check - "
"connect() failed."),
-1);
}
}
this->connected_socket_ = 1;
}
ACE_OS::memset (this->icmp_send_buff_, 0, sizeof this->icmp_send_buff_);
int datalen = ICMP_DATA_LENGTH;
struct icmp *_icmp;
_icmp = (struct icmp *) this->icmp_send_buff_;
_icmp->icmp_type = ICMP_ECHO;
_icmp->icmp_code = 0;
_icmp->icmp_id = getpid ();
_icmp->icmp_seq = sequence_number_++;
#if defined (ACE_WIN32)
_icmp->icmp_data = GetTickCount ();
#else /* #if defined (ACE_WIN32) */
gettimeofday ((struct timeval *) &_icmp->icmp_data, NULL);
#endif /* #if defined (ACE_WIN32) */
int length_icmp = ICMP_MIN + datalen; // checksum ICMP header and data.
_icmp->icmp_cksum = 0;
_icmp->icmp_cksum = inherited::calculate_checksum ((u_short *) _icmp,
length_icmp);
int rval_send = -1;
if ((rval_send = send ((void const *) icmp_send_buff_,
length_icmp,
remote_addr)) != length_icmp)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) ACE::Ping_Socket::send_echo_check - "
"send() failed, sent %d bytes instead of %d.\n",
rval_send, length_icmp),
-1);
}
return 0;
}
示例7: g
template <class HANDLER> int
ACE_Asynch_Acceptor<HANDLER>::open (const ACE_INET_Addr &address,
size_t bytes_to_read,
bool pass_addresses,
int backlog,
int reuse_addr,
ACE_Proactor *proactor,
bool validate_new_connection,
int reissue_accept,
int number_of_initial_accepts)
{
ACE_TRACE ("ACE_Asynch_Acceptor<>::open");
this->proactor (proactor);
this->pass_addresses_ = pass_addresses;
this->bytes_to_read_ = bytes_to_read;
this->validate_new_connection_ = validate_new_connection;
this->reissue_accept_ = reissue_accept;
this->addr_family_ = address.get_type ();
// Create the listener socket
this->listen_handle_ = ACE_OS::socket (address.get_type (), SOCK_STREAM, 0);
if (this->listen_handle_ == ACE_INVALID_HANDLE)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("ACE_OS::socket")),
-1);
// Initialize the ACE_Asynch_Accept
if (this->asynch_accept_.open (*this,
this->listen_handle_,
0,
this->proactor ()) == -1)
{
ACE_Errno_Guard g (errno);
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("ACE_Asynch_Accept::open")));
ACE_OS::closesocket (this->listen_handle_);
this->listen_handle_ = ACE_INVALID_HANDLE;
return -1;
}
if (reuse_addr)
{
// Reuse the address
int one = 1;
if (ACE_OS::setsockopt (this->listen_handle_,
SOL_SOCKET,
SO_REUSEADDR,
(const char*) &one,
sizeof one) == -1)
{
ACE_Errno_Guard g (errno);
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("ACE_OS::setsockopt")));
ACE_OS::closesocket (this->listen_handle_);
this->listen_handle_ = ACE_INVALID_HANDLE;
return -1;
}
}
// If port is not specified, bind to any port.
static ACE_INET_Addr sa (ACE_sap_any_cast (const ACE_INET_Addr &));
if (address == sa &&
ACE::bind_port (this->listen_handle_,
INADDR_ANY,
address.get_type()) == -1)
{
ACE_Errno_Guard g (errno);
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("ACE::bind_port")));
ACE_OS::closesocket (this->listen_handle_);
this->listen_handle_ = ACE_INVALID_HANDLE;
return -1;
}
// Bind to the specified port.
if (ACE_OS::bind (this->listen_handle_,
reinterpret_cast<sockaddr *> (address.get_addr ()),
address.get_size ()) == -1)
{
ACE_Errno_Guard g (errno);
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("ACE_OS::bind")));
ACE_OS::closesocket (this->listen_handle_);
this->listen_handle_ = ACE_INVALID_HANDLE;
return -1;
}
// Start listening.
if (ACE_OS::listen (this->listen_handle_, backlog) == -1)
{
ACE_Errno_Guard g (errno);
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("ACE_OS::listen")));
//.........这里部分代码省略.........