本文整理汇总了C++中ACE_Addr类的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Addr类的具体用法?C++ ACE_Addr怎么用?C++ ACE_Addr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ACE_Addr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
ssize_t
ACE_SOCK_Netlink::recv (iovec iov[],
int n,
ACE_Addr &addr,
int flags) const
{
ACE_TRACE ("ACE_SOCK_Netlink::recv");
msghdr recv_msg;
recv_msg.msg_iov = (iovec *) iov;
recv_msg.msg_iovlen = n;
recv_msg.msg_name = (char *) addr.get_addr ();
recv_msg.msg_namelen = addr.get_size ();
recv_msg.msg_control = 0;
recv_msg.msg_controllen = 0;
recv_msg.msg_flags = 0;
ssize_t status = ACE_OS::recvmsg (this->get_handle (),
&recv_msg,
flags);
if (recv_msg.msg_flags & MSG_TRUNC)
return -1;
addr.set_size (recv_msg.msg_namelen);
addr.set_type (((sockaddr_in *) addr.get_addr())->sin_family);
return status;
}
示例2: if
int
ACE_SOCK_Connector::connect (ACE_SOCK_Stream &new_stream,
const ACE_Addr &remote_sap,
ACE_QoS_Params qos_params,
const ACE_Time_Value *timeout,
const ACE_Addr &local_sap,
ACE_Protocol_Info * protocolinfo,
ACE_SOCK_GROUP g,
u_long flags,
int reuse_addr,
int /* perms */)
{
ACE_TRACE ("ACE_SOCK_Connector::connect");
if (this->shared_open (new_stream,
remote_sap.get_type (),
0,
protocolinfo,
g,
flags,
reuse_addr) == -1)
return -1;
else if (this->shared_connect_start (new_stream,
timeout,
local_sap) == -1)
return -1;
int result = ACE_OS::connect (new_stream.get_handle (),
reinterpret_cast<sockaddr *> (remote_sap.get_addr ()),
remote_sap.get_size (),
qos_params);
return this->shared_connect_finish (new_stream, timeout, result);
}
示例3: if
ssize_t
ACE_SOCK_Dgram::recv (iovec *io_vec,
ACE_Addr &addr,
int flags,
const ACE_Time_Value *timeout) const
{
ACE_TRACE ("ACE_SOCK_Dgram::recv");
#if defined (FIONREAD)
ACE_Handle_Set handle_set;
handle_set.reset ();
handle_set.set_bit (this->get_handle ());
// Check the status of the current socket to make sure there's data
// to recv (or time out).
int select_width;
# if defined (ACE_WIN64)
// This arg is ignored on Windows and causes pointer truncation
// warnings on 64-bit compiles.
select_width = 0;
# else
select_width = int (this->get_handle ()) + 1;
# endif /* ACE_WIN64 */
switch (ACE_OS::select (select_width,
handle_set,
0, 0,
timeout))
{
case -1:
return -1;
/* NOTREACHED */
case 0:
errno = ETIME;
return -1;
/* NOTREACHED */
default:
// Goes fine, fallthrough to get data
break;
}
sockaddr *saddr = (sockaddr *) addr.get_addr ();
int addr_len = addr.get_size ();
u_long inlen;
if (ACE_OS::ioctl (this->get_handle (),
FIONREAD, (u_long *) &inlen) == -1)
return -1;
else if (inlen > 0)
{
ACE_NEW_RETURN (io_vec->iov_base,
char[inlen],
-1);
io_vec->iov_len = ACE_OS::recvfrom (this->get_handle (),
(char *) io_vec->iov_base,
inlen,
flags,
(sockaddr *) saddr,
&addr_len);
addr.set_size (addr_len);
return io_vec->iov_len;
}
示例4: if
int
ACE_SOCK_Connector::connect (ACE_SOCK_Stream &new_stream,
const ACE_Addr &remote_sap,
const ACE_Time_Value *timeout,
const ACE_Addr &local_sap,
int reuse_addr,
int /* flags */,
int /* perms */,
int protocol)
{
ACE_TRACE ("ACE_SOCK_Connector::connect");
if (this->shared_open (new_stream,
remote_sap.get_type (),
protocol,
reuse_addr) == -1)
return -1;
else if (this->shared_connect_start (new_stream,
timeout,
local_sap) == -1)
return -1;
int result = ACE_OS::connect (new_stream.get_handle (),
reinterpret_cast<sockaddr *> (remote_sap.get_addr ()),
remote_sap.get_size ());
return this->shared_connect_finish (new_stream,
timeout,
result);
}
示例5: ACE_TRACE
int
ACE_SOCK_Connector::shared_connect_start (ACE_SOCK_Stream &new_stream,
const ACE_Time_Value *timeout,
const ACE_Addr &local_sap)
{
ACE_TRACE ("ACE_SOCK_Connector::shared_connect_start");
if (local_sap != ACE_Addr::sap_any)
{
sockaddr *laddr = reinterpret_cast<sockaddr *> (local_sap.get_addr ());
int size = local_sap.get_size ();
if (ACE_OS::bind (new_stream.get_handle (),
laddr,
size) == -1)
{
// Save/restore errno.
ACE_Errno_Guard error (errno);
new_stream.close ();
return -1;
}
}
// Enable non-blocking, if required.
if (timeout != 0
&& new_stream.enable (ACE_NONBLOCK) == -1)
return -1;
else
return 0;
}
示例6: complete
int
ACE_XTI_ATM_Mcast::add_leaf (ACE_TLI_Stream ¤t_stream,
const ACE_Addr &remote_sap,
ACE_INT32 leaf_id,
ACE_Time_Value *timeout)
{
ACE_TRACE ("ACE_XTI_ATM_Mcast::add_leaf");
struct netbuf call_req;
memset(&call_req, 0, sizeof(call_req));
call_req.len = remote_sap.get_size ();
call_req.buf = (char *)remote_sap.get_addr ();
if (::t_addleaf(current_stream.get_handle(),
leaf_id,
&call_req) < 0)
{
// Check for asynchronous event
if (t_errno == TLOOK)
{
int const event = ACE_OS::t_look(current_stream.get_handle());
if (event != TNODATA && event != T_DATA)
return -1;
else
// If this doesn't work for asynchronous calls we need to call
// the XTI/ATM t_rcvleafchange() function to check for t_addleaf
// completion.
return complete (current_stream, 0, timeout);
}
else
return -1;
}
return 0;
}
示例7:
ACE_CLASSIX_Port::ACE_CLASSIX_Port(ACE_Addr const& theAddr)
: ACE_CLASSIX_Addr (sizeof (ACE_CLASSIX_Port_Core::Addr))
{
if (theAddr.get_size() == this->get_size() &&
theAddr.get_type() == this->get_type())
this->set_(theAddr);
else
this->clear();
}
示例8:
int
ACE_TLI_Stream::get_remote_addr (ACE_Addr &sa) const
{
ACE_TRACE ("ACE_TLI_Stream::get_remote_addr");
struct netbuf name;
name.maxlen = sa.get_size ();
name.buf = (char *) sa.get_addr ();
if(ACE_OS::t_getname (this->get_handle (), &name, REMOTENAME) == -1)
return -1;
else
return 0;
}
示例9: ACE_TRACE
int
ACE_SOCK_Acceptor::open (const ACE_Addr &local_sap,
int reuse_addr,
int protocol_family,
int backlog,
int protocol)
{
ACE_TRACE ("ACE_SOCK_Acceptor::open");
if (local_sap != ACE_Addr::sap_any)
protocol_family = local_sap.get_type ();
else if (protocol_family == PF_UNSPEC)
{
#if defined (ACE_HAS_IPV6)
protocol_family = ACE::ipv6_enabled () ? PF_INET6 : PF_INET;
#else
protocol_family = PF_INET;
#endif /* ACE_HAS_IPV6 */
}
if (ACE_SOCK::open (SOCK_STREAM,
protocol_family,
protocol,
reuse_addr) == -1)
return -1;
else
return this->shared_open (local_sap,
protocol_family,
backlog);
}
示例10:
int
ACE_SOCK_Acceptor::open (const ACE_Addr &local_sap,
ACE_Protocol_Info *protocolinfo,
ACE_SOCK_GROUP g,
u_long flags,
int reuse_addr,
int protocol_family,
int backlog,
int protocol)
{
ACE_TRACE ("ACE_SOCK_Acceptor::open");
if (protocol_family == PF_UNSPEC)
protocol_family = local_sap.get_type ();
if (ACE_SOCK::open (SOCK_STREAM,
protocol_family,
protocol,
protocolinfo,
g,
flags,
reuse_addr) == -1)
return -1;
else
return this->shared_open (local_sap,
protocol_family,
backlog);
}
示例11:
int
ACE_SOCK::get_local_addr (ACE_Addr &sa) const
{
ACE_TRACE ("ACE_SOCK::get_local_addr");
int len = sa.get_size ();
sockaddr *addr = reinterpret_cast<sockaddr *> (sa.get_addr ());
if (ACE_OS::getsockname (this->get_handle (),
addr,
&len) == -1)
return -1;
sa.set_type (addr->sa_family);
sa.set_size (len);
return 0;
}
示例12: if
ssize_t
ACE_SOCK_Dgram::recv (iovec *io_vec,
ACE_Addr &addr,
int flags,
const ACE_Time_Value *timeout) const
{
ACE_TRACE ("ACE_SOCK_Dgram::recv");
#if defined (FIONREAD)
if( ACE::handle_read_ready (this->get_handle (), timeout) != 1 )
{
return -1;
}
sockaddr *saddr = (sockaddr *) addr.get_addr ();
int addr_len = addr.get_size ();
int inlen;
if (ACE_OS::ioctl (this->get_handle (),
FIONREAD,
&inlen) == -1)
return -1;
else if (inlen > 0)
{
ACE_NEW_RETURN (io_vec->iov_base,
char[inlen],
-1);
ssize_t rcv_len = ACE_OS::recvfrom (this->get_handle (),
(char *) io_vec->iov_base,
inlen,
flags,
(sockaddr *) saddr,
&addr_len);
if (rcv_len < 0)
{
delete [] (char *)io_vec->iov_base;
io_vec->iov_base = 0;
}
else
{
io_vec->iov_len = ACE_Utils::truncate_cast<u_long> (rcv_len);
addr.set_size (addr_len);
}
return rcv_len;
}
示例13: sendmsg
ssize_t
ACE_SOCK_Netlink::send (const iovec iov[],
int n,
const ACE_Addr &addr,
int flags) const
{
ACE_TRACE ("ACE_SOCK_Netlink::send");
msghdr send_msg;
send_msg.msg_iov = (iovec *) iov;
send_msg.msg_iovlen = n;
send_msg.msg_name = (char *) addr.get_addr ();
send_msg.msg_namelen = addr.get_size ();
send_msg.msg_control = 0;
send_msg.msg_controllen = 0;
send_msg.msg_flags = 0;
return ACE_OS::sendmsg (this->get_handle (),
&send_msg,
flags);
}
示例14: ACE_TRACE
int
ACE_SOCK_Connector::shared_connect_start (ACE_SOCK_Stream &new_stream,
const ACE_Time_Value *timeout,
const ACE_Addr &local_sap)
{
ACE_TRACE ("ACE_SOCK_Connector::shared_connect_start");
if (local_sap != ACE_Addr::sap_any)
{
sockaddr *laddr = ACE_reinterpret_cast (sockaddr *,
local_sap.get_addr ());
int size = local_sap.get_size ();
if (ACE_OS::bind (new_stream.get_handle (),
laddr,
size) == -1)
{
// Save/restore errno.
ACE_Errno_Guard error (errno);
new_stream.close ();
return -1;
}
}
示例15: if
int
SCTP_Connector::connect (ACE_SOCK_SEQPACK_Association &new_association,
const ACE_Addr &remote_sap,
const ACE_Time_Value *timeout,
const ACE_Addr &local_sap,
int reuse_addr,
int /* flags */,
int /* perms */,
int protocol)
{
ACE_TRACE ("SCTP_Connector::connect");
if (this->shared_open (new_association,
remote_sap.get_type (),
protocol,
reuse_addr) == -1)
return -1;
else if (this->shared_connect_start (new_association,
timeout,
local_sap) == -1)
return -1;
if (new_association.set_option(SOL_SCTP,
SCTP_HEARTBEAT_ITVL,
&heart_beat_,
sizeof(heart_beat_)) == -1)
return -1;
int result = ACE_OS::connect (new_association.get_handle (),
reinterpret_cast<sockaddr *> (remote_sap.get_addr ()),
remote_sap.get_size ());
return this->shared_connect_finish (new_association,
timeout,
result);
}