本文整理汇总了C++中ACE_Addr::set_size方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Addr::set_size方法的具体用法?C++ ACE_Addr::set_size怎么用?C++ ACE_Addr::set_size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_Addr
的用法示例。
在下文中一共展示了ACE_Addr::set_size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
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;
}
示例3:
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;
}
示例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)
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;
}