< prev index next >

src/java.base/unix/native/libnet/PlainSocketImpl.c

Print this page

        

@@ -44,10 +44,12 @@
 jfieldID psi_timeoutID;
 jfieldID psi_trafficClassID;
 jfieldID psi_fdLockID;
 jfieldID psi_closePendingID;
 
+extern void setDefaultScopeID(JNIEnv *env, struct sockaddr *him);
+
 /*
  * file descriptor used for dup2
  */
 static int marker_fd = -1;
 

@@ -257,10 +259,11 @@
     /* connect */
     if (NET_InetAddressToSockaddr(env, iaObj, port, &sa, &len,
                                   JNI_TRUE) != 0) {
         return;
     }
+    setDefaultScopeID(env, &sa.sa);
 
     if (trafficClass != 0 && ipv6_available()) {
         NET_SetTrafficClass(&sa, trafficClass);
     }
 

@@ -504,10 +507,11 @@
     /* bind */
     if (NET_InetAddressToSockaddr(env, iaObj, localport, &sa,
                                   &len, JNI_TRUE) != 0) {
         return;
     }
+    setDefaultScopeID(env, &sa.sa);
 
     if (NET_Bind(fd, &sa, len) < 0) {
         if (errno == EADDRINUSE || errno == EADDRNOTAVAIL ||
             errno == EPERM || errno == EACCES) {
             NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "BindException",
< prev index next >