//===-- SocketAddress.h -----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_SocketAddress_h_
#define liblldb_SocketAddress_h_
// C Includes
#include <stdint.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#if defined(__FreeBSD__)
#include <sys/types.h>
#endif
// C++ Includes
// Other libraries and framework includes
// Project includes
namespace lldb_private {
class SocketAddress
{
public:
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
SocketAddress ();
SocketAddress (const struct sockaddr &s);
SocketAddress (const struct sockaddr_in &s);
SocketAddress (const struct sockaddr_in6 &s);
SocketAddress (const struct sockaddr_storage &s);
SocketAddress (const SocketAddress& rhs);
~SocketAddress ();
//------------------------------------------------------------------
// Operators
//------------------------------------------------------------------
const SocketAddress&
operator=(const SocketAddress& rhs);
const SocketAddress&
operator=(const struct addrinfo *addr_info);
const SocketAddress&
operator=(const struct sockaddr &s);
const SocketAddress&
operator=(const struct sockaddr_in &s);
const SocketAddress&
operator=(const struct sockaddr_in6 &s);
const SocketAddress&
operator=(const struct sockaddr_storage &s);
//------------------------------------------------------------------
// Clear the contents of this socket address
//------------------------------------------------------------------
void
Clear ();
//------------------------------------------------------------------
// Get the length for the current socket address family
//------------------------------------------------------------------
socklen_t
GetLength () const;
//------------------------------------------------------------------
// Get the mex length for the the largest socket address supported.
//------------------------------------------------------------------
static socklen_t
GetMaxLength ();
//------------------------------------------------------------------
// Get the socket address family
//------------------------------------------------------------------
sa_family_t
GetFamily () const;
//------------------------------------------------------------------
// Set the socket address family
//------------------------------------------------------------------
void
SetFamily (sa_family_t family);
//------------------------------------------------------------------
// Get the port if the socket address for the family has a port
//------------------------------------------------------------------
in_port_t
GetPort () const;
//------------------------------------------------------------------
// Set the port if the socket address for the family has a port.
// The family must be set correctly prior to calling this function.
//------------------------------------------------------------------
bool
SetPort (in_port_t port);
//------------------------------------------------------------------
// Set the socket address according to the first match from a call
// to getaddrinfo() (or equivalent functions for systems that don't
// have getaddrinfo(). If "addr_info_ptr" is not NULL, it will get
// filled in with the match that was used to populate this socket
// address.
//------------------------------------------------------------------
bool
SetAddress (const struct addrinfo *hints_ptr, // Optional hints where the family, protocol and other things can be specified.
const char *host, // Hostname ("foo.bar.com" or "foo" or IP address string ("123.234.12.1" or "2001:0db8:85a3:0000:0000:8a2e:0370:7334")
const char *service, // Protocol name ("tcp", "http", etc) or a raw port number string ("81")
struct addrinfo *addr_info_ptr); // If non-NULL, this will get filled in with the match
//------------------------------------------------------------------
// Quick way to set the SocketAddress to localhost given the family.
// Returns true if successful, false if "family" doesn't support
// localhost or if "family" is not supported by this class.
//------------------------------------------------------------------
bool
SetToLocalhost (sa_family_t family,
in_port_t port);
//------------------------------------------------------------------
// Returns true if there is a valid socket address in this object.
//------------------------------------------------------------------
bool
IsValid () const;
//------------------------------------------------------------------
// Direct access to all of the sockaddr structures
//------------------------------------------------------------------
struct sockaddr &
sockaddr ()
{
return m_socket_addr.sa;
}
const struct sockaddr &
sockaddr () const
{
return m_socket_addr.sa;
}
struct sockaddr_in &
sockaddr_in ()
{
return m_socket_addr.sa_ipv4;
}
const struct sockaddr_in &
sockaddr_in () const
{
return m_socket_addr.sa_ipv4;
}
struct sockaddr_in6 &
sockaddr_in6 ()
{
return m_socket_addr.sa_ipv6;
}
const struct sockaddr_in6 &
sockaddr_in6 () const
{
return m_socket_addr.sa_ipv6;
}
struct sockaddr_storage &
sockaddr_storage ()
{
return m_socket_addr.sa_storage;
}
const struct sockaddr_storage &
sockaddr_storage () const
{
return m_socket_addr.sa_storage;
}
//------------------------------------------------------------------
// Conversion operators to allow getting the contents of this class
// as a pointer to the appropriate structure. This allows an instance
// of this class to be used in calls that take one of the sockaddr
// structure variants without having to manally use the correct
// accessor function.
//------------------------------------------------------------------
operator struct sockaddr * ()
{
return &m_socket_addr.sa;
}
operator const struct sockaddr * () const
{
return &m_socket_addr.sa;
}
operator struct sockaddr_in * ()
{
return &m_socket_addr.sa_ipv4;
}
operator const struct sockaddr_in * () const
{
return &m_socket_addr.sa_ipv4;
}
operator struct sockaddr_in6 * ()
{
return &m_socket_addr.sa_ipv6;
}
operator const struct sockaddr_in6 * () const
{
return &m_socket_addr.sa_ipv6;
}
operator const struct sockaddr_storage * () const
{
return &m_socket_addr.sa_storage;
}
operator struct sockaddr_storage * ()
{
return &m_socket_addr.sa_storage;
}
protected:
typedef union sockaddr_tag
{
struct sockaddr sa;
struct sockaddr_in sa_ipv4;
struct sockaddr_in6 sa_ipv6;
struct sockaddr_storage sa_storage;
} sockaddr_t;
//------------------------------------------------------------------
// Classes that inherit from SocketAddress can see and modify these
//------------------------------------------------------------------
sockaddr_t m_socket_addr;
};
} // namespace lldb_
没有合适的资源?快使用搜索试试~ 我知道了~
catch_class_02.rar_There There
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共3个文件
c:3个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 197 浏览量
2022-09-24
07:15:31
上传
评论
收藏 3KB RAR 举报
温馨提示
Returns true if there is a valid socket address in this object.
资源推荐
资源详情
资源评论
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![js](https://img-home.csdnimg.cn/images/20210720083646.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![text/x-c](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![text/plain](https://img-home.csdnimg.cn/images/20210720083646.png)
![chm](https://img-home.csdnimg.cn/images/20210720083646.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![epub](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 3 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/5df8bff20ad645abb899a1a8333a748d_weixin_42651281.jpg!1)
小波思基
- 粉丝: 74
- 资源: 1万+
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)