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

Function is_ip_address

dlib/sockets/sockets_extensions.cpp:279–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

277// ----------------------------------------------------------------------------------------
278
279 bool is_ip_address (
280 std::string ip
281 )
282 {
283 for (std::string::size_type i = 0; i < ip.size(); ++i)
284 {
285 if (ip[i] == '.')
286 ip[i] = ' ';
287 }
288 std::istringstream sin(ip);
289
290 bool bad = false;
291 int num;
292 for (int i = 0; i < 4; ++i)
293 {
294 sin >> num;
295 if (!sin || num < 0 || num > 255)
296 {
297 bad = true;
298 break;
299 }
300 }
301
302 if (sin.get() != EOF)
303 bad = true;
304
305 return !bad;
306 }
307
308// ----------------------------------------------------------------------------------------
309

Callers 4

connectFunction · 0.85
connect_toFunction · 0.85
set_listening_ipMethod · 0.85

Calls 2

sizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected