MCPcopy Create free account
hub / github.com/ReadyTalk/avian / Java_java_nio_channels_SocketChannel_natWrite

Function Java_java_nio_channels_SocketChannel_natWrite

classpath/java-nio.cpp:593–631  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

591}
592
593extern "C" JNIEXPORT jint JNICALL
594 Java_java_nio_channels_SocketChannel_natWrite(JNIEnv* e,
595 jclass,
596 jint socket,
597 jbyteArray buffer,
598 jint offset,
599 jint length,
600 jboolean blocking)
601{
602 int r;
603 if (blocking) {
604 uint8_t* buf = static_cast<uint8_t*>(allocate(e, length));
605 if (buf) {
606 e->GetByteArrayRegion(
607 buffer, offset, length, reinterpret_cast<jbyte*>(buf));
608 r = ::doWrite(socket, buf, length);
609 free(buf);
610 } else {
611 return 0;
612 }
613 } else {
614 jboolean isCopy;
615 uint8_t* buf
616 = static_cast<uint8_t*>(e->GetPrimitiveArrayCritical(buffer, &isCopy));
617
618 r = ::doWrite(socket, buf + offset, length);
619
620 e->ReleasePrimitiveArrayCritical(buffer, buf, 0);
621 }
622
623 if (r < 0) {
624 if (eagain()) {
625 return 0;
626 } else {
627 throwIOException(e);
628 }
629 }
630 return r;
631}
632
633extern "C" JNIEXPORT jint JNICALL
634 Java_java_nio_channels_DatagramChannel_write(JNIEnv* e,

Calls 5

freeFunction · 0.85
eagainFunction · 0.85
throwIOExceptionFunction · 0.85
allocateFunction · 0.70
doWriteFunction · 0.70

Tested by

no test coverage detected