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

Method readable

dlib/sockets/sockets_kernel_2.cpp:490–516  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

488// ----------------------------------------------------------------------------------------
489
490 bool connection::
491 readable (
492 unsigned long timeout
493 ) const
494 {
495 fd_set read_set;
496 // initialize read_set
497 FD_ZERO(&read_set);
498
499 // add the listening socket to read_set
500 FD_SET(connection_socket, &read_set);
501
502 // setup a timeval structure
503 timeval time_to_wait;
504 time_to_wait.tv_sec = static_cast<long>(timeout/1000);
505 time_to_wait.tv_usec = static_cast<long>((timeout%1000)*1000);
506
507 // wait on select
508 int status = select(connection_socket+1,&read_set,0,0,&time_to_wait);
509
510 // if select timed out or there was an error
511 if (status <= 0)
512 return false;
513
514 // socket is ready to be read
515 return true;
516 }
517
518// ----------------------------------------------------------------------------------------
519

Callers

nothing calls this directly

Calls 1

selectFunction · 0.50

Tested by

no test coverage detected