PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
vtkPlusOpenIGTLinkServerMacOSX.cxx
Go to the documentation of this file.
1 #include <arpa/inet.h>
2 #include <sys/socket.h>
3 #include <ifaddrs.h>
4 #include <stdio.h>
5 
7 {
8  struct ifaddrs* ifap, *ifa;
9  struct sockaddr_in* sa;
10  char* addr;
11 
12  std::vector<std::string> addresses;
13 
14  getifaddrs(&ifap);
15  for (ifa = ifap; ifa; ifa = ifa->ifa_next)
16  {
17  if (ifa->ifa_addr->sa_family == AF_INET)
18  {
19  sa = (struct sockaddr_in*) ifa->ifa_addr;
20  addr = inet_ntoa(sa->sin_addr);
21  addresses.push_back(addr);
22  }
23  }
24  freeifaddrs(ifap);
25 
26  std::stringstream ss;
27  ss << "Plus OpenIGTLink server listening on IPs: ";
28  for (unsigned int i = 0; i < addresses.size(); ++i)
29  {
30  ss << addresses[i];
31  if (i + 1 != addresses.size())
32  {
33  ss << ", ";
34  }
35  }
36  ss << " -- port " << self->GetListeningPort();
37  LOG_INFO(ss.str());
38 }
void PrintServerInfo(vtkPlusOpenIGTLinkServer *self)
for i
This class provides a network interface for data acquired by Plus as an OpenIGTLink server.