Hi all, I have been trying to implement socket classes for ATM network by wrapping JNI around the linux-atm 0.39 "C" code for linux-jdk-1.1.6v2. Recently I measured the round trip time (RTT) of this java implementation between two local machines in our atm network. It was found that RTT was as long as 60ms! Using a pure "C" program (no JNI), however, the measured RTT was only 0.5ms. Talking to an echo server implemented in pure "C", this JNI "C" code is used to track down the time spent in write() and read(): JNIEXPORT void JNICALL Java_rttClient_svcSocketWriteRead(JNIEnv *env, jobject callObj, jint sid, jbyteArray jdata, jint offset, jint len) { sigset_t alarmSet; struct timeval tv; jsize arrLen = (*env)->GetArrayLength(env, jdata); jbyte* buf = (*env)->GetByteArrayElements(env, jdata, 0); assert(arrLen >= (offset + len)); gettimeofday(&tv, NULL); txStamp = tv.tv_sec * 1000000 + tv.tv_usec; if (write(sid, (char *) buf+offset, len) < 0) myException(env, "write failed", "java/io/IOException"); gettimeofday(&tv, NULL); printf("after write -> waiting: %d\n", tv.tv_sec * 1000000 + tv.tv_usec - txStamp); rxBytes = read(sid, (char *) buf+offset, len); (*env)->ReleaseByteArrayElements(env, jdata, buf, 0); if (rxBytes < 0) return myException(env, "read failed", "java/io/IOException"); else if (rxBytes == 0) return myException(env, "remote end closed", "java/io/EOFException"); gettimeofday(&tv, NULL); printf("after read -> waiting: %d\n", tv.tv_sec * 1000000 + tv.tv_usec - txStamp); (*env)->ReleaseByteArrayElements(env, jdata, buf, 0); return; } It was found that it spent 0.1ms to complete write() and had to wait for 60ms before read() is returned. The funny part of this story is that if I do a "strace java rttClient > strace.output 2>&1" to my java program "rttClient", the RTT dropped down to around 2ms. Does anyone have a clue what is going on?? I looked around in the linux-jdk mailing archive, and was not sure if this infomation is related to my problem or not... (http://www.mail-archive.com/java-linux@java.blackdown.org/msg01451.html) "The v3 version of jdk116 uses non-blocking io for all io system calls including stdin (that was one of the fixes for v3). So user threads do not (should not!) block on io and the entire user based thread package does not stop." Any suggestions or comments are very much appreciated... Best Regards, Jonathan