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. **/
| 342 | </doc> |
| 343 | **/ |
| 344 | Array<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 |
nothing calls this directly
no test coverage detected