Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

io_tryread(3) [debian man page]

io_tryread(3)						     Library Functions Manual						     io_tryread(3)

NAME
io_tryread - read from a descriptor without blocking SYNTAX
#include <io.h> int io_tryread(int64 fd,char* buf,int64 len); DESCRIPTION
io_tryread tries to read len bytes of data from descriptor fd into buf[0], buf[1], ..., 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)

Check Out this Related Man Page

io_canread(3)						     Library Functions Manual						     io_canread(3)

NAME
io_canread - return a file descriptor that can be read from SYNTAX
#include <io.h> int64 io_canread(); DESCRIPTION
io_canread returns the next file descriptor that can be read from. You have to have used io_wantread() on the file descriptor earlier, and you have to have called io_wait() or io_waituntil(). These functions then keep an internal data structure on which descriptors were reported readable by the operating system. Please note that there is no guarantee that there still is data that can be read from the descriptor, just that there was data when io_wait() or io_waituntil() were called. Another process could have read the data before you. Look at the result from io_tryread(). If there are no more descriptors that you can write to without blocking, io_canwrite will return -1. In this case you should call io_wait() or io_waituntil() again. You should use io_tryread(3) to read from the descriptor, not plain read(2). If you use read(2) and you get EAGAIN, call io_eagain(3). SEE ALSO
io_wait(3), io_canwrite(3), io_eagain(3) io_canread(3)
Man Page

5 More Discussions You Might Find Interesting

1. Programming

problem in reading file using fread

Hi All, These are the two ways i tried to read file but i getting work with second one not with the first. char buf; // Defining space for buf ctrlfnum = fopen(filename_arr.control_fname,"r"); 1) n = fread(buf,sizeof(buf),1,ctrlfnum); ============== (not works) 2) n =... (4 Replies)
Discussion started by: arunkumar_mca
4 Replies

2. Shell Programming and Scripting

while read

I'm attempting to extract lines from a file where column lengths are fixed, e.g col1 len=5 col2 len=6... However if I do something like cat file |while read ans do ... The padding between each column is reduced to a space, is there an easy way to read the file with the original column... (3 Replies)
Discussion started by: gefa
3 Replies

3. UNIX for Dummies Questions & Answers

reading an already complied excutable file

Hi, I want ot read a executable file. Please let me know how to read it (4 Replies)
Discussion started by: richardsamuelk
4 Replies

4. Programming

How to use we use int64?

Recently my project needs int64 variables. However my os and computer are both 32bits. So how can i use int64 as a parameter in a function. and is int64 a structure as user-defined structures..... ??? thanx i am waiting for ur answer:rolleyes: (2 Replies)
Discussion started by: macroideal
2 Replies

5. Shell Programming and Scripting

Extract sequences of bytes from binary for differents blocks

Hello to all, I would like to search sequences of bytes inside big binary file. The bin file contains blocks of information, each block begins is estructured as follow: 1- Each block begins with the hex 32 (1 byte) and ends with FF. After the FF of the last block, it follows 33. 2- Next... (59 Replies)
Discussion started by: Ophiuchus
59 Replies