socket_write : 'socket -> string -> void Send the whole content of a string over a connected socket. **/
| 313 | <doc>Send the whole content of a string over a connected socket.</doc> |
| 314 | **/ |
| 315 | void _hx_std_socket_write( Dynamic o, Array<unsigned char> buf ) |
| 316 | { |
| 317 | SOCKET sock = val_sock(o); |
| 318 | int datalen = buf->length; |
| 319 | const char *cdata = (const char *)&buf[0]; |
| 320 | int pos = 0; |
| 321 | |
| 322 | hx::EnterGCFreeZone(); |
| 323 | while( datalen > 0 ) |
| 324 | { |
| 325 | POSIX_LABEL(write_again); |
| 326 | int slen = send(sock,cdata + pos,datalen,MSG_NOSIGNAL); |
| 327 | if( slen == SOCKET_ERROR ) { |
| 328 | HANDLE_EINTR(write_again); |
| 329 | block_error(); |
| 330 | } |
| 331 | pos += slen; |
| 332 | datalen -= slen; |
| 333 | } |
| 334 | hx::ExitGCFreeZone(); |
| 335 | } |
| 336 | |
| 337 | |
| 338 | /** |
nothing calls this directly
no test coverage detected