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

Function is_ip_address

dlib/sockets/sockets_extensions.cpp:261–288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

259// ----------------------------------------------------------------------------------------
260
261 bool is_ip_address (
262 std::string ip
263 )
264 {
265 for (std::string::size_type i = 0; i < ip.size(); ++i)
266 {
267 if (ip[i] == '.')
268 ip[i] = ' ';
269 }
270 std::istringstream sin(ip);
271
272 bool bad = false;
273 int num;
274 for (int i = 0; i < 4; ++i)
275 {
276 sin >> num;
277 if (!sin || num < 0 || num > 255)
278 {
279 bad = true;
280 break;
281 }
282 }
283
284 if (sin.get() != EOF)
285 bad = true;
286
287 return !bad;
288 }
289
290// ----------------------------------------------------------------------------------------
291

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