From: Bill Kelly Date: 2006-02-14T11:23:11+09:00 Subject: Re: nonblocking sockets, select, & OpenSSL Hi, From: > > Quoting rakaur : > >> SSLSocket#read doesn't behave as it should. If you specify a size >> (as I did earlier, 8192) it blocks until that many bytes have been >> read, > > I would expect that behavior from SSLSocket#read -- did you mean > SSLSocket#recv instead? NoMethodError: undefined method `recv' for # :( ...However, ! I see SSLSocket#read is implemented in pure ruby, and it's a buffering implementation (which provides a #readpartial). And it fills its buffer with SSLSocket#sysread, which apparently *does* support nonblocking I/O. From openssl/buffering.rb, which defines a Buffering module which is included into SSLSocket, and which is based on sysread and syswrite: private def fill_rbuff begin @rbuffer << self.sysread(BLOCK_SIZE) rescue Errno::EAGAIN retry rescue EOFError @eof = true end end So it looks like rakaur could either use readpartial (if he wants the pure-ruby Buffering implementation), or go down to SSLSocket#sysread and handle EAGAIN. Regards, Bill