MCPcopy Create free account
hub / github.com/OpenKinect/libfreenect2 / fillAddr

Function fillAddr

tools/streamer_recorder/PracticalSocket.cpp:65–79  ·  view source on GitHub ↗

Function to fill in address structure given an address and port

Source from the content-addressed store, hash-verified

63
64// Function to fill in address structure given an address and port
65static void fillAddr(const string &address, unsigned short port,
66 sockaddr_in &addr) {
67 memset(&addr, 0, sizeof(addr)); // Zero out address structure
68 addr.sin_family = AF_INET; // Internet address
69
70 hostent *host; // Resolve name
71 if ((host = gethostbyname(address.c_str())) == NULL) {
72 // strerror() will not work for gethostbyname() and hstrerror()
73 // is supposedly obsolete
74 throw SocketException("Failed to resolve name (gethostbyname())");
75 }
76 addr.sin_addr.s_addr = *((unsigned long *) host->h_addr_list[0]);
77
78 addr.sin_port = htons(port); // Assign port in network byte order
79}
80
81// Socket Code
82

Callers 3

connectMethod · 0.85
sendToMethod · 0.85

Calls 1

SocketExceptionClass · 0.85

Tested by

no test coverage detected