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

Function _hx_std_socket_set_timeout

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

socket_set_timeout : 'socket -> timout:number? -> void Set the socket send and recv timeout in seconds to the given value (or null for blocking) **/

Source from the content-addressed store, hash-verified

930 <doc>Set the socket send and recv timeout in seconds to the given value (or null for blocking)</doc>
931**/
932void _hx_std_socket_set_timeout( Dynamic o, Dynamic t )
933{
934 SOCKET sock = val_sock(o);
935
936#ifdef NEKO_WINDOWS
937 int time;
938 if( !t.mPtr )
939 time = 0;
940 else {
941 time = (int)((double)(t) * 1000);
942 }
943#else
944 struct timeval time;
945 if( t.mPtr==0 ) {
946 time.tv_usec = 0;
947 time.tv_sec = 0;
948 } else {
949 init_timeval(t,&time);
950 }
951#endif
952
953 hx::EnterGCFreeZone();
954 if( setsockopt(sock,SOL_SOCKET,SO_SNDTIMEO,(char*)&time,sizeof(time)) != 0 )
955 {
956 hx::ExitGCFreeZone();
957 return;
958 }
959 if( setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(char*)&time,sizeof(time)) != 0 )
960 {
961 hx::ExitGCFreeZone();
962 return;
963 }
964 hx::ExitGCFreeZone();
965}
966
967/**
968 socket_shutdown : 'socket -> read:bool -> write:bool -> void

Callers

nothing calls this directly

Calls 4

val_sockFunction · 0.85
init_timevalFunction · 0.85
EnterGCFreeZoneFunction · 0.85
ExitGCFreeZoneFunction · 0.85

Tested by

no test coverage detected