On Mon, Sep 08, 2014 at 11:16:46PM +0530, Alok Sharma wrote: > while ( (n = read(fd, recvBuff, sizeof(recvBuff)-1)) > 0) > { > recvBuff[n] = 0; > mode=n; > i=0; > while(mode>0) > { > len=SSL_write(ssl, recvBuff, mode); > total+=len; > mode=mode-len; > } > }
The inner loop is wrong unless all the data is always written on each SSL_write() call. > bytes = SSL_read(ssl, buf, sizeof(buf)); /* get reply & decrypt */ > buf[bytes] = 0; > printf("Received: \"%s\"\n", buf); > SSL_free(ssl); /* release connection state */ Why do you expect data back from the server? It is surely still waiting for more data from the client, since there is no explicit message framing to indicate to the server that all the data is sent, and it should reply. You're freeing the SSL state without a gracefull SSL_shutdown() (often called twice, see the docs). > while(1) > { > bytes = SSL_read(ssl, buf, sizeof(buf)); /* get request */ > if ( bytes > 0 ) > { > // printf("Client msg: \"%s\"\n", buf); > //sprintf(reply, HTMLecho, buf); /* construct reply */ > //SSL_write(ssl, reply, strlen(reply)); /* send reply */ > len=bytes; > mode=len; > while(mode>0) > { > len1=write(fd,buf,len); > mode=mode-len1; > len-=len1; > } > > } > else { > ERR_print_errors_fp(stderr); > break; > } > > } THe inner loop is wrong unless all the data is written on each write(2) call. The server is in an infinite read loop, deadlocked with the client. > } > sd = SSL_get_fd(ssl); /* get socket connection */ > SSL_free(ssl); /* release SSL state */ > close(sd); /* close connection */ And sends no reply. This code is broken, and should block forever with SSL_read()/SSL_write() replaced with read()/write(). Since you're reporting finite completion times, you're not posting the code you're testing, which wastes everyone's time. -- Viktor. ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org