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

Function get_local_hostname

dlib/sockets/sockets_kernel_1.cpp:97–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

sockets_startupFunction · 0.70

Tested by

no test coverage detected