I'm trying to use the sconnect-demo with Win32 but it does not work - the system crashes. (V 0.9.5) I found bugs: 1) the internal random generator is not initialized in the sample and writes some internal error messages. 2)The function ERR_print_errors_fp() (file err_prn.c) in the sample crashes because of large return value from calling ERR_get_error_line_data() and an overflow in the fprintf() function next line. 3) the state of the socket is changing to BIO_CONN_S_OK but the socket is not connected. ********** fix 1) I dont find out why ERR_print_errors_fp crashes but if you add this code (file sconnect.c) after BIO_push() the random generator is initialized. #if defined(WIN16) || defined(WIN32) RAND_screen(); NoiseHeavy(); NoiseLight(); #endif Because Windows has not a "random device" like unix it would be nice to integrate the NoiseHeavy() and NoiseLight() functions into the rand-Module for a better seed. #if defined(WIN16) || defined(WIN32) void NoiseHeavy() { #if defined(WIN16) struct _find_t finddata; char szWinpath[260]; unsigned h; if (0<GetWindowsDirectory(szWinpath, sizeof(szWinpath))) { strcat(szWinpath, "\\*"); h = _dos_findfirst(szWinpath, _A_NORMAL, &finddata); if (h!=0) { do { RAND_seed((unsigned char*)&finddata, sizeof(finddata)); } while ((0==_dos_findnext(&finddata))); } } #else HANDLE hSrch; WIN32_FIND_DATA finddata; TCHAR szWinpath[MAX_PATH+3]; GetWindowsDirectory(szWinpath, sizeof(szWinpath)); tcscat(szWinpath, _T("\\*")); hSrch = FindFirstFile(szWinpath, &finddata); if (INVALID_HANDLE_VALUE!=hSrch) { do { RAND_seed((unsigned char*)&finddata, sizeof(finddata)); } while (FindNextFile(hSrch, &finddata)); FindClose(hSrch); } #endif } void NoiseLight() { #if defined(WIN16) DWORD dw[2]; dw[0] = GetFreeSpace(0); dw[1] = GetTickCount(); RAND_seed((unsigned char*)&dw, sizeof(dw)); #else SYSTEMTIME systime; DWORD dw[2]; BOOL f; SYSTEM_POWER_STATUS pwrstat; MEMORYSTATUS memstat; GetSystemTime(&systime); RAND_seed((unsigned char*)&systime, sizeof(systime)); GetSystemTimeAdjustment(&dw[0], &dw[1], &f); RAND_seed((unsigned char*)&dw, sizeof(dw)); if (GetSystemPowerStatus(&pwrstat)) /* only notebooks */ RAND_seed((unsigned char*)&pwrstat, sizeof(pwrstat)); GlobalMemoryStatus(&memstat); RAND_seed((unsigned char*)&memstat, sizeof(memstat)); #endif } #endif ********** fix 2) Dont know a solution, but if you fix 1) there are no errors ;-) ********** fix 3) Dont switch to the state "BIO_CONN_S_OK" if you are not connected! This code runs unter Win32, i have not tested it under other systems. BIO Module, file bss_conn.c: case BIO_CONN_S_BLOCKED_CONNECT: i=BIO_sock_error(b->num); if (0>i) { BIO_clear_retry_flags(b); SYSerr(SYS_F_CONNECT,i); ERR_add_error_data(4,"host=", c->param_hostname, ":",c->param_port); BIOerr(BIO_F_CONN_STATE,BIO_R_NBIO_CONNECT_ERROR); ret=0; goto exit_loop; } if (0<i) { c->state=BIO_CONN_S_OK; break; } goto exit_loop; /* not connected yet, we wait... */ BIO Module, file b_sock.c: static const struct timeval s_timevalWaitConnect = { 0, 200}; /* return -1 Error * return 0 Not connected yet, please wait... * return 1 connected */ int BIO_sock_error(int sock) { int j,i; int size; int nSelect; FD_SET writefds; FD_SET exceptfds; size=sizeof(int); /* Note: under Windows the third parameter is of type (char *) * whereas under other systems it is (void *) if you don't have * a cast it will choke the compiler: if you do have a cast then * you can either go for (char *) or (void *). */ i=getsockopt(sock,SOL_SOCKET,SO_ERROR,(void *)&j,(void *)&size); if (0!=i) return(-1); /* err rk */ /* rk new code */ FD_ZERO(&writefds); FD_ZERO(&exceptfds); FD_SET(sock, &writefds); FD_SET(sock, &exceptfds); nSelect = select(0, NULL, &writefds, &exceptfds, &s_timevalWaitConnect); if (SOCKET_ERROR==nSelect) return (-1); /*Err */ if (0==nSelect) return (0); /* time expired but not connected. Wait... */ if (FD_ISSET(sock, &exceptfds)) return (-1); /* Err connect */ if (FD_ISSET(sock, &writefds)) return (1); /* ooh, connected */ return (-1); // any other error } Bye, Ralf ============================================ Dipl.-Ing. (BA) Ralf Kunoth Application Development fun communications GmbH Brauerstrasse 6, D-76135 Karlsruhe, Germany fon: +49 721 96448-0, fax: +49 721 96448-22 http://www.fun.de, mailto:[EMAIL PROTECTED] I trust in http://www.keytrust.de ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]