![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Permission file questions--Please read!!! | bobo | UNIX for Dummies Questions & Answers | 4 | 02-10-2007 08:03 PM |
| Blocking file read | cubathy | High Level Programming | 2 | 07-01-2006 05:28 AM |
| blocking DHCP | byblyk | IP Networking | 2 | 03-15-2005 09:06 PM |
| School Blocking | Satine | IP Networking | 1 | 02-07-2005 02:07 PM |
| blocking domains | tamemi | UNIX for Dummies Questions & Answers | 1 | 04-16-2003 04:13 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
questions about non-blocking read()
Hi,
I need to read incoming data from a serial port. I also need the read() to be non-blocking, such that my program can then check for any data to be send via the serial port. I followed some FAQs on the net, set read() to be non-blocking, and got EAGAIN errors popping out. I realise that under non-blocking mode, it is normal to receive EAGAIN errors. Thus, the next thing I did, is try using select(). Is select() also blocking? How do I use select()? Can someone provide me some codes or any directions to get started on select()? Thanks! |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Is this what you were looking for?
http://beej.us/guide/bgnet/output/ht....html#blocking |
|
#3
|
|||
|
|||
|
Quote:
There are three sets of filedescriptors, those for reading, those for writing and those for exceptional conditions, a file descriptor may be in multiple sets. When you get EGAIN or EWOULDBLOCK use select to tell you when the filedescriptor is ready again. fd_set fds; FD_ZERO(&fds); FD_SET(fd,&fds); i=select(fd+1,&fds,NULL,NULL,NULL); if (i>0) { if (FD_ISSET(fd,&fds)) { do your thing ) } |
|
#4
|
|||
|
|||
|
Hey thanks for the replies.
It really helps |
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|