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

Function _hx_std_socket_write

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

socket_write : 'socket -> string -> void Send the whole content of a string over a connected socket. **/

Source from the content-addressed store, hash-verified

313 <doc>Send the whole content of a string over a connected socket.</doc>
314**/
315void _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/**

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected