if (bind(sockfd, (struct sockaddr *)&ss, len)) {
len = SA_LEN((struct sockaddr *)&ss); if (bind(sockfd, (struct sockaddr *)&ss, len) == 0) {
JNIEXPORT void JNICALL Java_java_net_PlainSocketImpl_bind  (JNIEnv *env, jobject this, jobject host, jint port){	struct sockaddr_storage 	ss;	struct sockaddr_in			*sin;	struct sockaddr_in6			*sin6;	jbyte *addrBytes = NULL;	jbyteArray addrByteArray;	int addrlen = 0;	int len = 0;	int sockfd = getSocketFileDescriptor(env, this);#ifdef DEBUG	printf("NATIVE: PlainSocketImpl.bind(): entering\n");#endif	/* if host is not null then bind to the supplied address */	if (host != NULL)  {		jclass hostClass = (*env)->GetObjectClass(env, host);		jfieldID addrID = (*env)->GetFieldID(env, hostClass, "address", "[B");		addrByteArray = (jbyteArray)(*env)->GetObjectField(env, host, addrID);		addrlen = (*env)->GetArrayLength(env, addrByteArray);		addrBytes = (*env)->GetByteArrayElements(env, addrByteArray, NULL);	}	/* were given an IPv4 address */	if (addrlen == 4) {		sin = (struct sockaddr_in *)&ss;		sin->sin_family = AF_INET;		memcpy(&sin->sin_addr, addrBytes, addrlen);		sin->sin_port = htons(port);		len = sizeof(struct sockaddr_in);	/* an IPv6 address */	} else if (addrlen == 16) {		sin6 = (struct sockaddr_in6 *)&ss;		sin6->sin6_family = AF_INET6;		memcpy(&sin6->sin6_addr, addrBytes, addrlen);		sin6->sin6_port = htons(port);		len = sizeof(struct sockaddr_in6);	} else if (addrlen == 0 && host != NULL) {		goto error;	}	if (bind(sockfd, (struct sockaddr *)&ss, len)) {		jint lport;		jclass thisClass = (*env)->GetObjectClass(env, this);		/* get the this.address field */		jfieldID addrID = (*env)->GetFieldID(env, thisClass, "address",											"Ljava/net/InetAddress;");		jobject addrObject = (*env)->GetObjectField(env, this, addrID);		/* get the this.localport field */		jfieldID localportID = (*env)->GetFieldID(env, thisClass, "localport", "I");		/* set this.address to host */		(*env)->SetObjectField(env, addrObject, addrID, host);		if (port != 0) {			/* set this.localport to port */			lport = port;		} else if ((getsockname(sockfd, (struct sockaddr *)&ss, &len)) == 0) {			/* set this.localport to ss.sin_port */			lport = ntohs(getSockAddrPort(&ss));		} else {			goto error;		}		(*env)->SetIntField(env, this, localportID, lport);#ifdef DEBUG	printf("NATIVE: PlainSocketImpl.bind(): returning\n");#endif		return;	}	error:#ifdef DEBUG	printf("NATIVE: PlainSocketImpl.bind(): throwing\n");#endif		throwException(env, EX_BIND, strerror(errno));		return;}