slidershim
slidershim copied to clipboard
Recommendation: Specify in the README that you can use USB tethering to connect.
It's recommended to indicate in the README that USB tethering can be used for connection to achieve the lowest latency.
Actually, as long as the IP address is correct, theoretically, a connection can be established even between the two sides of the world; it's not limited to the same Wi-Fi network or LAN. (Of course, latency might be high.)
Furthermore, the IP address listing section could be improved.
Here's my method for listing IP addresses:
void listLocalIPsAndAdapters() {
ULONG outBufLen = 16360;
std::vector<BYTE> buffer(outBufLen);
IP_ADAPTER_ADDRESSES* addresses = reinterpret_cast<IP_ADAPTER_ADDRESSES*>(buffer.data());
ULONG res = GetAdaptersAddresses(AF_INET, GAA_FLAG_INCLUDE_PREFIX, nullptr, addresses, &outBufLen);
if (ERROR_BUFFER_OVERFLOW == res) {
buffer.resize(outBufLen);
res = GetAdaptersAddresses(AF_INET, GAA_FLAG_INCLUDE_PREFIX, nullptr, addresses, &outBufLen);
}
if(NO_ERROR != res){
printError("Failed to get adapter addresses\n");
return;
}
std::string str;
str.reserve(2024);
str += "=== Local network interfaces ===\n";
char utf8buffer[2048]; utf8buffer[0] = '\0';
for (auto* adapter = addresses; adapter; adapter = adapter->Next) {
if (adapter->OperStatus != IfOperStatusUp) continue;
if (!adapter->FirstUnicastAddress) continue;
str += '[';
boost::nowide::narrow(utf8buffer, sizeof(utf8buffer), adapter->FriendlyName);
str += utf8buffer;
str += "] ";
boost::nowide::narrow(utf8buffer, sizeof(utf8buffer), adapter->Description);
str += utf8buffer;
str += '\n';
for (auto* ua = adapter->FirstUnicastAddress; ua; ua = ua->Next) {
sockaddr_in* sa_in = reinterpret_cast<sockaddr_in*>(ua->Address.lpSockaddr);
inet_ntop(AF_INET, &(sa_in->sin_addr), utf8buffer, sizeof(utf8buffer));
str += "\tIPv4: ";
str += utf8buffer;
str += '\n';
}
str += '\n';
}
std::print("{}", str);
}
Example output:
=== Local network interfaces ===
[乙太網路 6] VirtualBox Host-Only Ethernet Adapter
IPv4: 192.168.56.1
[區域連線* 2] Microsoft Wi-Fi Direct Virtual Adapter #2
IPv4: 192.168.137.1
[乙太網路] Realtek PCIe GbE Family Controller
IPv4: 156.134.139.27
[乙太網路 2] SAMSUNG Mobile USB Remote NDIS Network Device
IPv4: 10.93.191.238
[Loopback Pseudo-Interface 1] Software Loopback Interface 1
IPv4: 127.0.0.1