jdk/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c
changeset 18253 4323a5fe8bc4
parent 18192 fa6bd0992104
parent 17925 e8d88b57f82e
child 19866 f5e8a8275078
equal deleted inserted replaced
18252:1a7454a9febb 18253:4323a5fe8bc4
   143 }
   143 }
   144 
   144 
   145 /*
   145 /*
   146  * This function returns JNI_TRUE if the datagram size exceeds the underlying
   146  * This function returns JNI_TRUE if the datagram size exceeds the underlying
   147  * provider's ability to send to the target address. The following OS
   147  * provider's ability to send to the target address. The following OS
   148  * oddies have been observed :-
   148  * oddities have been observed :-
   149  *
   149  *
   150  * 1. On Windows 95/98 if we try to send a datagram > 12k to an application
   150  * 1. On Windows 95/98 if we try to send a datagram > 12k to an application
   151  *    on the same machine then the send will fail silently.
   151  *    on the same machine then the send will fail silently.
   152  *
   152  *
   153  * 2. On Windows ME if we try to send a datagram > supported by underlying
   153  * 2. On Windows ME if we try to send a datagram > supported by underlying
   216                 maxmsg = DEFAULT_MSG_SIZE;
   216                 maxmsg = DEFAULT_MSG_SIZE;
   217             }
   217             }
   218 
   218 
   219             /*
   219             /*
   220              * Step 3: On Windows 95/98 then enumerate the IP addresses on
   220              * Step 3: On Windows 95/98 then enumerate the IP addresses on
   221              * this machine. This is necesary because we need to check if the
   221              * this machine. This is neccesary because we need to check if the
   222              * datagram is being sent to an application on the same machine.
   222              * datagram is being sent to an application on the same machine.
   223              */
   223              */
   224             if (is95or98) {
   224             if (is95or98) {
   225                 char hostname[255];
   225                 char hostname[255];
   226                 struct hostent *hp;
   226                 struct hostent *hp;
   564 
   564 
   565     fdc = family == IPv4? fd: fd1;
   565     fdc = family == IPv4? fd: fd1;
   566 
   566 
   567     if (xp_or_later) {
   567     if (xp_or_later) {
   568         /* SIO_UDP_CONNRESET fixes a bug introduced in Windows 2000, which
   568         /* SIO_UDP_CONNRESET fixes a bug introduced in Windows 2000, which
   569          * returns connection reset errors un connected UDP sockets (as well
   569          * returns connection reset errors on connected UDP sockets (as well
   570          * as connected sockets. The solution is to only enable this feature
   570          * as connected sockets). The solution is to only enable this feature
   571          * when the socket is connected
   571          * when the socket is connected
   572          */
   572          */
   573         DWORD x1, x2; /* ignored result codes */
   573         DWORD x1, x2; /* ignored result codes */
   574         int res, t = TRUE;
   574         int res, t = TRUE;
   575         res = WSAIoctl(fdc,SIO_UDP_CONNRESET,&t,sizeof(t),&x1,sizeof(x1),&x2,0,0);
   575         res = WSAIoctl(fdc,SIO_UDP_CONNRESET,&t,sizeof(t),&x1,sizeof(x1),&x2,0,0);
   689         return;
   689         return;
   690     }
   690     }
   691     fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
   691     fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
   692 
   692 
   693     packetBufferLen = (*env)->GetIntField(env, packet, dp_lengthID);
   693     packetBufferLen = (*env)->GetIntField(env, packet, dp_lengthID);
       
   694     /* Note: the buffer needn't be greater than 65,536 (0xFFFF)...
       
   695      * the maximum size of an IP packet. Anything bigger is truncated anyway.
       
   696      */
       
   697     if (packetBufferLen > MAX_PACKET_LEN) {
       
   698         packetBufferLen = MAX_PACKET_LEN;
       
   699     }
   694 
   700 
   695     if (connected) {
   701     if (connected) {
   696         addrp = 0; /* arg to JVM_Sendto () null in this case */
   702         addrp = 0; /* arg to JVM_Sendto () null in this case */
   697         addrlen = 0;
   703         addrlen = 0;
   698     } else {
   704     } else {
   727                 return;
   733                 return;
   728             }
   734             }
   729         }
   735         }
   730 
   736 
   731         /* When JNI-ifying the JDK's IO routines, we turned
   737         /* When JNI-ifying the JDK's IO routines, we turned
   732          * read's and write's of byte arrays of size greater
   738          * reads and writes of byte arrays of size greater
   733          * than 2048 bytes into several operations of size 2048.
   739          * than 2048 bytes into several operations of size 2048.
   734          * This saves a malloc()/memcpy()/free() for big
   740          * This saves a malloc()/memcpy()/free() for big
   735          * buffers.  This is OK for file IO and TCP, but that
   741          * buffers.  This is OK for file IO and TCP, but that
   736          * strategy violates the semantics of a datagram protocol.
   742          * strategy violates the semantics of a datagram protocol.
   737          * (one big send) != (several smaller sends).  So here
   743          * (one big send) != (several smaller sends).  So here