4 #pragma comment(lib, "Iphlpapi.lib") 9 PIP_ADAPTER_ADDRESSES pAddresses = NULL;
10 ULONG outBufferSize = 0;
12 DWORD ipv4StringBufferLength = 63;
15 outBufferSize = 15 * 1024;
19 pAddresses = (IP_ADAPTER_ADDRESSES*)HeapAlloc(GetProcessHeap(), 0, (outBufferSize));
21 if (pAddresses == NULL)
26 dwRetVal = GetAdaptersAddresses(AF_INET, GAA_FLAG_INCLUDE_PREFIX, NULL, pAddresses, &outBufferSize);
28 if (dwRetVal == ERROR_BUFFER_OVERFLOW)
30 HeapFree(GetProcessHeap(), 0, (pAddresses));
40 while ((dwRetVal == ERROR_BUFFER_OVERFLOW) && (iterations < 3));
42 std::vector<std::string> addresses;
44 if (dwRetVal == NO_ERROR)
46 PIP_ADAPTER_ADDRESSES pCurrAddresses = pAddresses;
47 while (pCurrAddresses)
49 PIP_ADAPTER_UNICAST_ADDRESS pUnicast = pCurrAddresses->FirstUnicastAddress;
52 for (
unsigned int i = 0; pUnicast != NULL;
i++)
54 sockaddr_in* sa_in = (sockaddr_in*)pUnicast->Address.lpSockaddr;
55 std::string
address = inet_ntoa(sa_in->sin_addr);
57 pUnicast = pUnicast->Next;
61 pCurrAddresses = pCurrAddresses->Next;
67 HeapFree(GetProcessHeap(), 0, (pAddresses));
71 ss <<
"Plus OpenIGTLink server listening on IPs: ";
72 for (
unsigned int i = 0;
i < addresses.size(); ++
i)
75 if (
i + 1 != addresses.size())
80 ss <<
" -- port " <<
self->GetListeningPort();
This class provides a network interface for data acquired by Plus as an OpenIGTLink server.
void PrintServerInfo(vtkPlusOpenIGTLinkServer *self)