From: Seth Kurtzberg Date: 2003-02-27T17:25:23+09:00 Subject: Re: Unable to do non-blocking read on socket As I said, I can't use recv() or sysread() without destroying the design of my program. There is no good reason that I can't get non-blocking reads unless I use recv() or sysread(). The documentation clearly states that I can use fcntl(), and refers me to the man page for fcntl(). Another possible solution would be to use some sort of PEEK call to find out how much data is currently available, and then call IO#read() for that amount of data. I did verify with strace that the proper fcntl call does occur, with flags O_RDWR | O_NONBLOCK (O_RDWR set by default and retrieved by an fcntl call with F_GETFL, and O_NONBLOCK or'd with it). Here is the line from strace: fcntl64(8, F_SETFL, O_RDWR|O_NONBLOCK) = 0 The call is IO#read(32256), producing this message: wrong number of arguments(5 for 4) As I said, using the debugger changes the output, so I can't get any further information. I put print statements before and after the read call, to make sure that the exception is raised on the IO#read() call. On Thursday 27 February 2003 01:16 am, Yukihiro Matsumoto wrote: > Hi, > > In message "Unable to do non-blocking read on socket" > > on 03/02/27, Seth Kurtzberg writes: > |I have not been able to change the behavior of IO::read() to non-blocking. > |Calling the fcntl method and setting the NONBLOCK flag (and/or the NDELAY > |flag) has no effect on the behavior of IO::read(). > > We need no summary, we need code, and its exact output. > > In general, IO#read does lot more than read(2), use IO#sysread or > IO#recv, without mixing other reading methods. > > matz. -- Seth Kurtzberg M. I. S. Corp. 480-661-1849 seth@cql.com