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

Method readable

dlib/sockets/sockets_kernel_1.cpp:398–424  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

396// ----------------------------------------------------------------------------------------
397
398 bool connection::
399 readable (
400 unsigned long timeout
401 ) const
402 {
403 fd_set read_set;
404 // initialize read_set
405 FD_ZERO(&read_set);
406
407 // add the listening socket to read_set
408 FD_SET(connection_socket, &read_set);
409
410 // setup a timeval structure
411 timeval time_to_wait;
412 time_to_wait.tv_sec = static_cast<long>(timeout/1000);
413 time_to_wait.tv_usec = static_cast<long>((timeout%1000)*1000);
414
415 // wait on select
416 int status = select(0,&read_set,0,0,&time_to_wait);
417
418 // if select timed out or there was an error
419 if (status <= 0)
420 return false;
421
422 // data is ready to be read
423 return true;
424 }
425
426// ----------------------------------------------------------------------------------------
427

Callers

nothing calls this directly

Calls 1

selectFunction · 0.50

Tested by

no test coverage detected