althepal has asked for the wisdom of the Perl Monks concerning the following question:
I'm using select(4 arg) and sysread() to read a socket. I've noticed some strange behavior that I didn't expect, and I'm looking for some insight.
First of all, I've noticed that when a signal comes in (e.g. HUP) during select(), the function returns -1. I haven't seen this documented anywhere. Is this new to perl5.8? I know signal handling has been improved in 5.8, is there any detailed doc on this?
Also, I always thought that sysread() was non-blocking, but when there is no data to read, sysread() blocks. Is there any way to grab whatever data is on the socket (if any), without blocking? I know it sounds funny, but I don't completely trust select() to tell me that there's something to read. I want to double check when select() times out that there really is nothing on the socket. Should I just use an alarm to time out sysread()?
Finally, I was told a few days ago that sysread() should be given a value to read equivalent to my system's buffer size. Is this information correct? I don't see this documented anywhere? Can it hurt to tell sysread() to read in a much larger value? What if I tell it to read in 100K? Will chaos ensue? Is my system's buffer size the maximum size that sysread() will read?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: select() and sysread()
by salva (Canon) on Apr 27, 2005 at 12:58 UTC | |
|
Re: select() and sysread()
by polettix (Vicar) on Apr 27, 2005 at 13:05 UTC | |
|
Re: select() and sysread()
by zentara (Cardinal) on Apr 28, 2005 at 12:23 UTC |