在.NET C ++应用程序中连接到网络

时间:2017-04-18 06:44:26

标签: .net winforms c++-cli wifi

我正在使用C ++ .NET开发一个Windows窗体应用程序,并尝试连接到无线网络并检索网络状态详细信息,如SSID和连接。我试过看看wininet,但似乎该库不提供本地网络功能。这样做最简单的方法是什么?任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

使用Boost C ++库进行连接,它提供了用于网络编程的类,Boost Asio是特定的。

示例代码段:

asio::ip::tcp::socket socket(io_service);
// Do all your accepting and other stuff here.

asio::ip::tcp::endpoint remote_ep = socket.remote_endpoint();
asio::ip::address remote_ad = remote_ep.address();
std::string s = remote_ad.to_string();

一行转换:

asio::ip::tcp::socket socket(io_service);
// Do all your accepting and other stuff here.

std::string s = socket.remote_endpoint().address().to_string();

我不确定它为您的查询提供的功能,但肯定是网络编程的最佳选择之一。我没有使用任何与SSID相关的内容。

PS:Boost提供跨平台支持。