io_nonblock(3) Library Functions Manual io_nonblock(3)NAME
io_nonblock - switch to non-blocking I/O
void io_nonblock(int64 fd);
io_nonblock puts UNIX descriptor fd into ``non-blocking mode.'' Calling io_nonblock(fd) before io_fd(fd) makes io_tryread and io_trywrite
faster and more efficient.
Actually, current UNIX kernels do not support non-blocking descriptors; they support non-blocking open files. Furthermore, many programs
will break if they encounter non-blocking mode. This means that you must not use io_nonblock for a descriptor inherited from another pro-
io_nonblock has no return value; it always succeeds. If d is not the number of a UNIX descriptor, io_nonblock has no effect.
If io_fd is given a descriptor in blocking mode, io_tryread and io_trywrite go through the following contortions to avoid blocking:
1 Stop if poll says that the descriptor is not ready. Otherwise there's a good chance, but not a guarantee: even if poll says the descrip-
tor is ready, the descriptor might not be ready a moment later. (Furthermore, poll can fail on some systems.)
2 Catch SIGALRM. SIGALRM must not be blocked, and must not be used elsewhere in the program.
3 Set an interval timer so that any blocking call will be interrupted by SIGALRM within 10 milliseconds. (Current UNIX kernels do not
allow any shorter interval.) Of course, this may still mean a 10-millisecond delay.
If io_fd is given a descriptor in non-blocking mode (or a descriptor for a regular disk file), io_tryread and io_trywrite avoid these con-
SEE ALSO io_wait(3), io_canwrite(3)io_nonblock(3)
Check Out this Related Man Page
io_tryread(3) Library Functions Manual io_tryread(3)NAME
io_tryread - read from a descriptor without blocking
int io_tryread(int64 fd,char* buf,int64 len);
io_tryread tries to read len bytes of data from descriptor fd into buf, buf, ..., buf[len-1]. (The effects are undefined if len is 0
or smaller.) There are several possible results:
o o_tryread returns an integer between 1 and len: This number of bytes was available for immediate reading; the bytes were read into the
beginning of buf. Note that this number can be, and often is, smaller than len; you must not assume that io_tryread always succeeds in
reading exactly len bytes.
o io_tryread returns 0: No bytes were read, because the descriptor is at end of file. For example, this descriptor has reached the end of
a disk file, or is reading an empty pipe that has been closed by all writers.
o io_tryread returns -1, setting errno to EAGAIN: No bytes were read, because the descriptor is not ready. For example, the descriptor is
reading an empty pipe that could still be written to.
o io_tryread returns -3, setting errno to something other than EAGAIN: No bytes were read, because the read attempt encountered a persis-
tent error, such as a serious disk failure (EIO), an unreachable network (ENETUNREACH), or an invalid descriptor number (EBADF).
io_tryread does not pause waiting for a descriptor that is not ready. If you want to pause, use io_waitread or io_wait.
You can make io_tryread faster and more efficient by making the socket non-blocking with io_nonblock().
SEE ALSO io_nonblock(3), io_waitread(3), io_tryreadtimeout(3)io_tryread(3)
I'm a newbie in UNIX system, and I must do some IP and port blocking... (ex: www.hotmail.com or yahoomessenger)
How is the best way to do that?!
If anyone could give me a step by step help!
thanks (5 Replies)
Hi i dont know about the UNIX OS at all but now as my Project requires, i need to learn it as soon as possible.
Could anybody please help me out in suggessting any good elementary book on UNIX OS so that atleast i can learn the commands for UNIX servers and at the same time within the short span... (3 Replies)
hi all UNIX Gurus,
this is my first post...so i posting this with great expectations:o...hoping to get the similar replies...
my question is....
need to get timestamp with millisecond in UNIX. Date command gives Year,month day, hour,minute and second but it does not give millisecond.
Any... (5 Replies)
Can any of your UNIX gurus recommend a good online resource for learning UNIX scripting? I'll be doing a little bit of it, but not enough for me to feel motivated enough to go out and buy a book on it. Well, that, and I'm cheap!
dstins (3 Replies)
I have a .z file which i understand to be UNIX.
I'm on PC (no UNIX boxes) and have tried many different unzipping programs to extract this .z file, but only PicoZip has allowed me to view what is inside (telling me, i think, that it's not corrupt), but i have not been able to extract... (3 Replies)
I have updated the backend hosting for UNIX.COM and would appreciate feedback either in the form of a vote in the poll or a post so that we can plan for more changes if any are needed.
In particular let me us know if you see any strange behavior from the site as there may still be some... (8 Replies)
1) I want UNIX but I don't want to partition my hard drive. I have heard of programs that allow you to start UNIX from Windows but I don't know which one is good. Something like WinLinux (not too sure???) Anyone know which programs I'm talking about?
2) Is Linux UNIX?
3) How do you pronounce... (9 Replies)
I have a general question about storage vs. unix job
I am currently a unix admin with 2 years experience in a major financial institute. I have a chance to move up one level (2nd level) in UNIX in the near future. But I am also interested in Storage, which we have an seperate team... (4 Replies)
I will be taking a UNIX course as a part of my college Data Com concentration curriculum. Just thought it would be a good idea to get a little head start, since this class will most likely be quite difficult for someone like me. I never did any programming and I never dealt with Unix or Linux short... (3 Replies)
If I explicity ignore a signal (for example, SIGALRM), and this signal is generated during a blocking system call (for example, a recvfrom() ), what happens to the system call?
Does it abort, or does it remain blocked until its end? (2 Replies)
I am the ultimate noob when it comes to UNIX. Apart from a few basic thing like ls -l and mkdir (and that really is about as good as it gets) I know absolutely nothing about UNIX and I want to learn it and get better!
I'm sure like with most things, just getting stuck in and trying... (3 Replies)
Hey guys, this is my first time posting here (although I've been reading the forums for a while now). I'm looking for a good UNIX (or UNIX based/UNIX-like) distro to install on an old Dell Dimension 2400 Destop. I've done ALOT of research on the different distros and I've tried a few out but I... (6 Replies)