PRErrorCode err = PR_GetError(); switch( err ) { case PR_ADDRESS_NOT_AVAILABLE_ERROR: JSS_throwMsg(env, SOCKET_EXCEPTION, "Binding exception: address not available"); break; case PR_ADDRESS_IN_USE_ERROR: JSS_throwMsg(env, SOCKET_EXCEPTION, "Binding exception: address in use"); break; default: JSS_throwMsg(env, SOCKET_EXCEPTION, "Binding exception"); break; }
JSS_throwMsgPrErr(env, SOCKET_EXCEPTION, "Failed to bind socket");
Java_org_mozilla_jss_ssl_SocketBase_socketBind    (JNIEnv *env, jobject self, jbyteArray addrBA, jint port){    JSSL_SocketData *sock;    PRNetAddr addr;    jbyte *addrBAelems = NULL;    PRStatus status;    if( JSSL_getSockData(env, self, &sock) != PR_SUCCESS) {        /* exception was thrown */        goto finish;    }    /*     * setup the PRNetAddr structure     */    addr.inet.family = AF_INET;    addr.inet.port = htons(port);    if( addrBA != NULL ) {        PR_ASSERT(sizeof(addr.inet.ip) == 4);        PR_ASSERT( (*env)->GetArrayLength(env, addrBA) == 4);        addrBAelems = (*env)->GetByteArrayElements(env, addrBA, NULL);        if( addrBAelems == NULL ) {            ASSERT_OUTOFMEM(env);            goto finish;        }        memcpy(&addr.inet.ip, addrBAelems, 4);    } else {        addr.inet.ip = PR_htonl(INADDR_ANY);    }    /* do the bind() call */    status = PR_Bind(sock->fd, &addr);    if( status != PR_SUCCESS ) {        PRErrorCode err = PR_GetError();        switch( err ) {          case PR_ADDRESS_NOT_AVAILABLE_ERROR:            JSS_throwMsg(env, SOCKET_EXCEPTION,                "Binding exception: address not available");            break;          case PR_ADDRESS_IN_USE_ERROR:            JSS_throwMsg(env, SOCKET_EXCEPTION,                "Binding exception: address in use");            break;          default:            JSS_throwMsg(env, SOCKET_EXCEPTION,                "Binding exception");            break;        }        goto finish;    }       finish:    if( addrBAelems != NULL ) {        (*env)->ReleaseByteArrayElements(env, addrBA, addrBAelems, JNI_ABORT);    }}