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?
In reply to select() and sysread() by althepal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |