SmartOS/Net/NetUri.h

37 lines
718 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef _NetUri_H_
#define _NetUri_H_
#include "IPAddress.h"
#include "IPEndPoint.h"
// 协议类型
enum class NetType
{
Unknown = 0,
Tcp = 6,
Udp = 17,
Http = 80,
};
// 网络资源
class NetUri
{
public:
IPAddress Address; // 地址
ushort Port; // 端口
NetType Type; // 协议类型
String Host; // 远程地址字符串格式可能是IP字符串
NetUri();
NetUri(const String& uri);
NetUri(NetType type, const IPAddress& addr, ushort port);
NetUri(NetType type, const String& host, ushort port);
bool IsTcp() const { return Type == NetType::Tcp; }
bool IsUdp() const { return Type == NetType::Udp; }
String ToString() const;
};
#endif