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

Function _hx_std_socket_read

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

socket_read : 'socket -> string Read the whole content of a the data available from a socket until the connection close. If the socket hasn't been close by the other side, the function might block. **/

Source from the content-addressed store, hash-verified

342 </doc>
343**/
344Array<unsigned char> _hx_std_socket_read( Dynamic o )
345{
346 SOCKET sock = val_sock(o);
347 Array<unsigned char> result = Array_obj<unsigned char>::__new();
348 char buf[256];
349
350 hx::EnterGCFreeZone();
351 while( true )
352 {
353 POSIX_LABEL(read_again);
354 int len = recv(sock,buf,256,MSG_NOSIGNAL);
355 if( len == SOCKET_ERROR ) {
356 HANDLE_EINTR(read_again);
357 block_error();
358 }
359 if( len == 0 )
360 break;
361
362 hx::ExitGCFreeZone();
363 result->memcpy(result->length, (unsigned char *)buf, len );
364 hx::EnterGCFreeZone();
365 }
366
367 hx::ExitGCFreeZone();
368 return result;
369}
370
371/**
372 host_resolve : string -> 'int32

Callers

nothing calls this directly

Calls 5

val_sockFunction · 0.85
__newFunction · 0.85
EnterGCFreeZoneFunction · 0.85
ExitGCFreeZoneFunction · 0.85
block_errorFunction · 0.70

Tested by

no test coverage detected