(PHP 4 >= 4.2.0, PHP 5 < 5.1.0)

dio_readReads bytes from a file descriptor


dio_read(resource $fd, int $len = 1024): string

The function dio_read() reads and returns len bytes from file with descriptor fd.



The file descriptor returned by dio_open().


The number of bytes to read. If not specified, dio_read() reads 1K sized block.

Return Values

The bytes read from fd.

See Also

  • dio_write() - Writes data to fd with optional truncation at length

add a note

User Contributed Notes 2 notes

matt at vhub dot com
18 years ago
Note that dio_read on Windows (other platforms unknown) will not timeout if there is no data to read. There is no way to specify a timeout or do a non-blocking read on Windows.
14 years ago
I am using dio functions on windows to read RS232 port.
I can read/write but it seems that the write function cannot be binary.

In particular:
dio_write($com1,chr(10),1); will result in writing 2 bytes 0D 0A be cause \n is translated to \r\n. I have not found any way to overcome this limitation so far
To Top