< prev index next >

src/java.base/windows/native/libnet/net_util_md.c

Print this page




 950     for (i = 0; i < 16; i++) {
 951         if (caddr1[i] != caddr2[i]) {
 952             return 0; /* false */
 953         }
 954     }
 955     return 1;
 956 }
 957 
 958 /**
 959  * Wrapper for select/poll with timeout on a single file descriptor.
 960  *
 961  * flags (defined in net_util_md.h can be any combination of
 962  * NET_WAIT_READ, NET_WAIT_WRITE & NET_WAIT_CONNECT.
 963  *
 964  * The function will return when either the socket is ready for one
 965  * of the specified operation or the timeout expired.
 966  *
 967  * It returns the time left from the timeout, or -1 if it expired.
 968  */
 969 
 970 jint
 971 NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout)
 972 {
 973     jlong prevTime = JVM_CurrentTimeMillis(env, 0);
 974     jint read_rv;
 975 
 976     while (1) {
 977         jlong newTime;
 978         fd_set rd, wr, ex;
 979         struct timeval t;
 980 
 981         t.tv_sec = timeout / 1000;
 982         t.tv_usec = (timeout % 1000) * 1000;
 983 
 984         FD_ZERO(&rd);
 985         FD_ZERO(&wr);
 986         FD_ZERO(&ex);
 987         if (flags & NET_WAIT_READ) {
 988           FD_SET(fd, &rd);
 989         }
 990         if (flags & NET_WAIT_WRITE) {




 950     for (i = 0; i < 16; i++) {
 951         if (caddr1[i] != caddr2[i]) {
 952             return 0; /* false */
 953         }
 954     }
 955     return 1;
 956 }
 957 
 958 /**
 959  * Wrapper for select/poll with timeout on a single file descriptor.
 960  *
 961  * flags (defined in net_util_md.h can be any combination of
 962  * NET_WAIT_READ, NET_WAIT_WRITE & NET_WAIT_CONNECT.
 963  *
 964  * The function will return when either the socket is ready for one
 965  * of the specified operation or the timeout expired.
 966  *
 967  * It returns the time left from the timeout, or -1 if it expired.
 968  */
 969 
 970 JNIEXPORT jint JNICALL
 971 NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout)
 972 {
 973     jlong prevTime = JVM_CurrentTimeMillis(env, 0);
 974     jint read_rv;
 975 
 976     while (1) {
 977         jlong newTime;
 978         fd_set rd, wr, ex;
 979         struct timeval t;
 980 
 981         t.tv_sec = timeout / 1000;
 982         t.tv_usec = (timeout % 1000) * 1000;
 983 
 984         FD_ZERO(&rd);
 985         FD_ZERO(&wr);
 986         FD_ZERO(&ex);
 987         if (flags & NET_WAIT_READ) {
 988           FD_SET(fd, &rd);
 989         }
 990         if (flags & NET_WAIT_WRITE) {


< prev index next >