55 lines
703 B
C++
55 lines
703 B
C++
/**
|
|
* @file dl_net.h
|
|
* @brief 网络系统
|
|
*
|
|
*
|
|
* @version 1.0
|
|
* @author lveyou
|
|
* @date 23-10-30
|
|
*
|
|
* @note 基于asio
|
|
*/
|
|
#pragma once
|
|
|
|
#include <asio.hpp>
|
|
|
|
#include "io/dl_log.h"
|
|
|
|
namespace dl
|
|
{
|
|
class Network
|
|
{
|
|
public:
|
|
Network()
|
|
{
|
|
Debug();
|
|
}
|
|
/**
|
|
* @brief 返回主机名
|
|
*/
|
|
static std::string GetHostName()
|
|
{
|
|
return asio::ip::host_name();
|
|
}
|
|
/**
|
|
* @brief 返回本机ip
|
|
*/
|
|
//static std::string GetIpAddress()
|
|
//{
|
|
// asio::io_context io;
|
|
// asio::ip::udp::resolver r{ io };
|
|
// asio::query q{ udp::v4(), "google.com", "" };
|
|
|
|
//}
|
|
|
|
void Debug()
|
|
{
|
|
log_msg("----------------网络信息-------------\n"
|
|
"主机名:\n{}"
|
|
"",
|
|
GetHostName());
|
|
}
|
|
};
|
|
|
|
extern Network* g_net;
|
|
} |