MCPcopy Create free account
hub / github.com/davisking/dlib / get_local_hostname

Function get_local_hostname

dlib/sockets/sockets_kernel_1.cpp:98–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96 // lookup functions
97
98 int
99 get_local_hostname (
100 std::string& hostname
101 )
102 {
103 // ensure that WSAStartup has been called and WSACleanup will eventually
104 // be called when program ends
105 sockets_startup();
106
107 try
108 {
109
110 char temp[NI_MAXHOST];
111 if (gethostname(temp,NI_MAXHOST) == SOCKET_ERROR )
112 {
113 return OTHER_ERROR;
114 }
115
116 hostname = temp;
117 }
118 catch (...)
119 {
120 return OTHER_ERROR;
121 }
122
123 return 0;
124 }
125
126// -----------------
127

Callers

nothing calls this directly

Calls 1

sockets_startupFunction · 0.70

Tested by

no test coverage detected