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

Method read

dlib/sockets/sockets_kernel_2.cpp:409–444  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

407// ----------------------------------------------------------------------------------------
408
409 long connection::
410 read (
411 char* buf,
412 long num
413 )
414 {
415 long status;
416 const long max_recv_length = 1024*1024*100;
417 while (true)
418 {
419 // Make sure to cap the max value num can take on so that if it is
420 // really large (it might be big on 64bit platforms) so that the OS
421 // can't possibly get upset about it being large.
422 const long length = std::min(max_recv_length, num);
423 status = recv(connection_socket,buf,length,0);
424 if (status == -1)
425 {
426 // if recv was interupted then try again
427 if (errno == EINTR)
428 continue;
429 else
430 {
431 if (sd_called())
432 return SHUTDOWN;
433 else
434 return OTHER_ERROR;
435 }
436 }
437 else if (status == 0 && sd_called())
438 {
439 return SHUTDOWN;
440 }
441
442 return status;
443 } // while (true)
444 }
445// ----------------------------------------------------------------------------------------
446
447 long connection::

Callers

nothing calls this directly

Calls 1

minFunction · 0.50

Tested by

no test coverage detected