本文整理汇总了C++中ACE_Addr::get_size方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Addr::get_size方法的具体用法?C++ ACE_Addr::get_size怎么用?C++ ACE_Addr::get_size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_Addr
的用法示例。
在下文中一共展示了ACE_Addr::get_size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例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: error
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;
}
示例4: 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;
}
示例5:
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;
}
示例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:
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;
}
示例10: 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;
}
示例11: 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);
}
示例12: error
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;
}
}
示例13: 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);
}
示例14: if
int
ACE_SOCK_Acceptor::shared_open (const ACE_Addr &local_sap,
int protocol_family,
int backlog)
{
ACE_TRACE ("ACE_SOCK_Acceptor::shared_open");
int error = 0;
#if defined (ACE_HAS_IPV6)
if (protocol_family == PF_INET6)
{
sockaddr_in6 local_inet6_addr;
ACE_OS::memset (reinterpret_cast<void *> (&local_inet6_addr),
0,
sizeof local_inet6_addr);
if (local_sap == ACE_Addr::sap_any)
{
local_inet6_addr.sin6_family = AF_INET6;
local_inet6_addr.sin6_port = 0;
local_inet6_addr.sin6_addr = in6addr_any;
}
else
local_inet6_addr = *reinterpret_cast<sockaddr_in6 *> (local_sap.get_addr ());
# if defined (ACE_WIN32)
// on windows vista and later, Winsock can support dual stack sockets
// but this must be explicitly set prior to the bind. Since this
// behavior is the default on *nix platforms, it should be benigh to
// just do it here. On older platforms the setsockopt will fail, but
// that should be OK.
int zero = 0;
ACE_OS::setsockopt (this->get_handle (),
IPPROTO_IPV6,
IPV6_V6ONLY,
(char *)&zero,
sizeof (zero));
# endif /* ACE_WIN32 */
// We probably don't need a bind_port written here.
// There are currently no supported OS's that define
// ACE_LACKS_WILDCARD_BIND.
if (ACE_OS::bind (this->get_handle (),
reinterpret_cast<sockaddr *> (&local_inet6_addr),
sizeof local_inet6_addr) == -1)
error = 1;
}
else
#endif
if (protocol_family == PF_INET)
{
sockaddr_in local_inet_addr;
ACE_OS::memset (reinterpret_cast<void *> (&local_inet_addr),
0,
sizeof local_inet_addr);
if (local_sap == ACE_Addr::sap_any)
{
local_inet_addr.sin_port = 0;
}
else
local_inet_addr = *reinterpret_cast<sockaddr_in *> (local_sap.get_addr ());
if (local_inet_addr.sin_port == 0)
{
if (ACE::bind_port (this->get_handle (),
ACE_NTOHL (ACE_UINT32 (local_inet_addr.sin_addr.s_addr))) == -1)
error = 1;
}
else if (ACE_OS::bind (this->get_handle (),
reinterpret_cast<sockaddr *> (&local_inet_addr),
sizeof local_inet_addr) == -1)
error = 1;
}
else if (ACE_OS::bind (this->get_handle (),
(sockaddr *) local_sap.get_addr (),
local_sap.get_size ()) == -1)
error = 1;
if (error != 0
|| ACE_OS::listen (this->get_handle (),
backlog) == -1)
{
ACE_Errno_Guard g (errno); // Preserve across close() below.
error = 1;
this->close ();
}
return error ? -1 : 0;
}
示例15: if
int
ACE_TLI_Connector::connect (ACE_TLI_Stream &new_stream,
const ACE_Addr &remote_sap,
ACE_Time_Value *timeout,
const ACE_Addr &local_sap,
int reuse_addr,
int flags,
int /* perms */,
const char device[],
struct t_info *info,
int rwf,
struct netbuf *udata,
struct netbuf *opt)
{
ACE_TRACE ("ACE_TLI_Connector::connect");
int result = 0;
// Only open a new endpoint if we don't already have a valid handle.
if (new_stream.get_handle () == ACE_INVALID_HANDLE
&& new_stream.open (device, flags, info) == ACE_INVALID_HANDLE)
return -1;
if (local_sap != ACE_Addr::sap_any)
{
// Bind the local endpoint to a specific addr.
struct t_bind *localaddr;
localaddr = (struct t_bind *)
ACE_OS::t_alloc (new_stream.get_handle (), T_BIND, T_ADDR);
if (localaddr == 0)
result = -1;
else
{
int one = 1;
#if !defined (ACE_HAS_FORE_ATM_XTI)
// Reusing the address causes problems with FORE's API. The
// issue may be that t_optmgmt isn't fully supported by
// FORE. t_errno is TBADOPT after the t_optmgmt call so
// maybe options are configured differently for XTI than for
// TLI (at least for FORE's implementation - XTI is supposed
// to be a superset of TLI).
if (reuse_addr
&& new_stream.set_option (SOL_SOCKET,
SO_REUSEADDR,
&one,
sizeof one) == -1)
result = -1;
else
#endif /* ACE_HAS_FORE_ATM_XTI */
{
void *addr_buf = local_sap.get_addr ();
localaddr->addr.len = local_sap.get_size ();
ACE_OS::memcpy(localaddr->addr.buf,
addr_buf,
localaddr->addr.len);
if (ACE_OS::t_bind (new_stream.get_handle (),
localaddr,
localaddr) == -1)
result = -1;
ACE_OS::t_free ((char *) localaddr,
T_BIND);
}
}
if (result == -1)
{
new_stream.close ();
return -1;
}
}
// Let TLI select the local endpoint addr.
else if (ACE_OS::t_bind (new_stream.get_handle (), 0, 0) == -1)
return -1;
struct t_call *callptr = 0;
callptr = (struct t_call *)
ACE_OS::t_alloc (new_stream.get_handle (), T_CALL, T_ADDR);
if (callptr == 0)
{
new_stream.close ();
return -1;
}
void *addr_buf = remote_sap.get_addr ();
callptr->addr.len = remote_sap.get_size ();
ACE_OS::memcpy (callptr->addr.buf,
addr_buf,
callptr->addr.len);
//callptr->addr.buf = (char *) remote_sap.get_addr ();
if (udata != 0)
ACE_OS::memcpy ((void *) &callptr->udata, (void *) udata, sizeof *udata);
if (opt != 0)
//.........这里部分代码省略.........