Skip to content

Commit

Permalink
Added early deterministic fail when no TAP adapter is available on Wi…
Browse files Browse the repository at this point in the history
…ndows (#71)
  • Loading branch information
ereOn committed Apr 15, 2015
1 parent f74b835 commit 20894fd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions libs/asiotap/src/windows/windows_tap_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ namespace asiotap
{
const guid_map_type tap_adapters_map = enumerate_tap_adapters();

if (tap_adapters_map.empty()) {
throw std::runtime_error("No tap adapter found. You may want to relaunch the installer to install one.");
}

for (auto&& tap_adapter : tap_adapters_map)
{
if (!tap_adapter.first.empty())
Expand All @@ -185,6 +189,8 @@ namespace asiotap
}
}
}

throw std::runtime_error("Some tap adapters were found but none could be opened. Are they all in use already ?");
}

void windows_tap_adapter::open(const std::string& _name, boost::system::error_code& ec)
Expand All @@ -193,9 +199,7 @@ namespace asiotap

if (_name.empty())
{
open(ec);

return;
return open(ec);
}

PIP_ADAPTER_INFO piai = NULL;
Expand Down

0 comments on commit 20894fd

Please sign in to comment.