jdk/src/solaris/native/sun/nio/ch/SctpNet.c
changeset 4678 99fdf34405de
parent 4675 68f287672813
child 4814 dbf72872f8d2
--- a/jdk/src/solaris/native/sun/nio/ch/SctpNet.c	Mon Jan 18 14:01:07 2010 +0000
+++ b/jdk/src/solaris/native/sun/nio/ch/SctpNet.c	Mon Jan 18 14:56:06 2010 +0000
@@ -110,6 +110,38 @@
     return JNI_TRUE;
 }
 
+jint
+handleSocketError(JNIEnv *env, jint errorValue)
+{
+    char *xn;
+    switch (errorValue) {
+        case EINPROGRESS:     /* Non-blocking connect */
+            return 0;
+        case EPROTO:
+            xn= JNU_JAVANETPKG "ProtocolException";
+            break;
+        case ECONNREFUSED:
+            xn = JNU_JAVANETPKG "ConnectException";
+            break;
+        case ETIMEDOUT:
+            xn = JNU_JAVANETPKG "ConnectException";
+            break;
+        case EHOSTUNREACH:
+            xn = JNU_JAVANETPKG "NoRouteToHostException";
+            break;
+        case EADDRINUSE:  /* Fall through */
+        case EADDRNOTAVAIL:
+            xn = JNU_JAVANETPKG "BindException";
+            break;
+        default:
+            xn = JNU_JAVANETPKG "SocketException";
+            break;
+    }
+    errno = errorValue;
+    JNU_ThrowByNameWithLastError(env, xn, "NioSocketError");
+    return IOS_THROWN;
+}
+
 /*
  * Class:     sun_nio_ch_SctpNet
  * Method:    init