On Mon, Nov 26, 2001 at 11:39:26AM +0100, Rygg Christian Ingemann wrote: > Hi! > > I'm making a few objects that are communicating with eachother using SSL. It > almost works now, but I want my client to read from the connection until > there are no more to read, without knowing how much the server is sending. I > thought using SSL_pending() would do the trick. However, the call to > SSL_pending() always returns 0, even though there is something to read: If I > comment it out, the client reads line after line, but hangs when there is no > more to read. Why does it return 0 if there is something to read?
SSL_pending() only returns the number of bytes that are still buffered. The data are sent in blocks, and if the last SSL_read() operation did not retrieve all bytes from this block, SSL_pending() will tell you how many bytes are left. (Consider a block of 100 bytes. If SSL_read() only queried 50 bytes, SSL_pending() will tell you, that 50 bytes are left.) If no bytes are currently in the buffer, SSL_pending will return 0, only the next call to SSL_read() will trigger the processing of the next block of bytes. If you want to know, whether there are still data coming from the peer, you must use non-blocking sockets and select() on read, when the buffer is empty. Best regards, Lutz -- Lutz Jaenicke [EMAIL PROTECTED] BTU Cottbus http://www.aet.TU-Cottbus.DE/personen/jaenicke/ Lehrstuhl Allgemeine Elektrotechnik Tel. +49 355 69-4129 Universitaetsplatz 3-4, D-03044 Cottbus Fax. +49 355 69-4153 ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]