prStatus = PR_Close(sslSocket); if (prStatus != PR_SUCCESS) { errWarn("PR_Close"); }
do_connects(void *a, int connection){	PRNetAddr  *addr = (PRNetAddr *)a;	PRFileDesc *sslSocket;	PRHostEnt   hostEntry;	char        buffer[PR_NETDB_BUF_SIZE];	PRStatus    prStatus;	PRIntn      hostenum;	PRInt32    ip;	SECStatus   secStatus;	/* Set up SSL secure socket. */	sslSocket = setupSSLSocket(addr);	if (sslSocket == NULL) {		errWarn("setupSSLSocket");		return SECFailure;	}	secStatus = SSL_SetPKCS11PinArg(sslSocket, password);	if (secStatus != SECSuccess) {		errWarn("SSL_SetPKCS11PinArg");		return secStatus;	}	secStatus = SSL_SetURL(sslSocket, hostName);	if (secStatus != SECSuccess) {		errWarn("SSL_SetURL");		return secStatus;	}	/* Prepare and setup network connection. */	prStatus = PR_GetHostByName(hostName, buffer, sizeof(buffer), &hostEntry);	if (prStatus != PR_SUCCESS) {		errWarn("PR_GetHostByName");		return SECFailure;	}	hostenum = PR_EnumerateHostEnt(0, &hostEntry, port, addr);	if (hostenum == -1) {		errWarn("PR_EnumerateHostEnt");		return SECFailure;	} 	ip = PR_ntohl(addr->inet.ip);	fprintf(stderr,	 	"Connecting to host %s (addr %d.%d.%d.%d) on port %d\n",			hostName, BYTE(3,ip), BYTE(2,ip), BYTE(1,ip), 			BYTE(0,ip), PR_ntohs(addr->inet.port)); 	prStatus = PR_Connect(sslSocket, addr, PR_INTERVAL_NO_TIMEOUT);	if (prStatus != PR_SUCCESS) {		errWarn("PR_Connect");		return SECFailure;	}	/* Established SSL connection, ready to send data. */#if 0	secStatus = SSL_ForceHandshake(sslSocket);	if (secStatus != SECSuccess) {		errWarn("SSL_ForceHandshake");		return secStatus;	}#endif	secStatus = SSL_ResetHandshake(sslSocket, /* asServer */ PR_FALSE);	if (secStatus != SECSuccess) {		errWarn("SSL_ResetHandshake");		prStatus = PR_Close(sslSocket);		if (prStatus != PR_SUCCESS) {			errWarn("PR_Close");		}		return secStatus;	}	secStatus = handle_connection(sslSocket, connection);	if (secStatus != SECSuccess) {		/* error already printed out in handle_connection */		/* errWarn("handle_connection"); */		return secStatus;	}	PR_Close(sslSocket);	return SECSuccess;}