MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / _hx_std_socket_select

Function _hx_std_socket_select

src/hx/libs/std/Socket.cpp:719–751  ·  view source on GitHub ↗

socket_select : read : 'socket array -> write : 'socket array -> others : 'socket array -> timeout:number? -> 'socket array array Perform the [select] operation. Timeout is in seconds or [null] if infinite **/

Source from the content-addressed store, hash-verified

717 <doc>Perform the [select] operation. Timeout is in seconds or [null] if infinite</doc>
718**/
719Array<Dynamic> _hx_std_socket_select( Array<Dynamic> rs, Array<Dynamic> ws, Array<Dynamic> es, Dynamic timeout )
720{
721 SOCKET n = 0;
722 fd_set rx, wx, ex;
723 fd_set *ra, *wa, *ea;
724
725 POSIX_LABEL(select_again);
726 ra = make_socket_array(rs,&rx,&n);
727 wa = make_socket_array(ws,&wx,&n);
728 ea = make_socket_array(es,&ex,&n);
729 if( ra == &INVALID || wa == &INVALID || ea == &INVALID )
730 hx::Throw( HX_CSTRING("No valid sockets") );
731
732 struct timeval tval;
733 struct timeval *tt = 0;
734 if( timeout.mPtr )
735 tt = init_timeval(timeout,&tval);
736
737 hx::EnterGCFreeZone();
738 if( select((int)(n+1),ra,wa,ea,tt) == SOCKET_ERROR )
739 {
740 hx::ExitGCFreeZone();
741 HANDLE_EINTR(select_again);
742 hx::Throw( HX_CSTRING("Select error ") + String((int)errno) );
743 }
744 hx::ExitGCFreeZone();
745
746 Array<Dynamic> r = Array_obj<Dynamic>::__new(3,3);
747 r[0] = make_array_result(rs,ra);
748 r[1] = make_array_result(ws,wa);
749 r[2] = make_array_result(es,ea);
750 return r;
751}
752
753/**
754 socket_select : read : 'socket array -> write : 'socket array -> others : 'socket array -> timeout:number?

Callers

nothing calls this directly

Calls 9

make_socket_arrayFunction · 0.85
ThrowFunction · 0.85
init_timevalFunction · 0.85
EnterGCFreeZoneFunction · 0.85
selectFunction · 0.85
ExitGCFreeZoneFunction · 0.85
__newFunction · 0.85
make_array_resultFunction · 0.85
StringClass · 0.50

Tested by

no test coverage detected