I am writing a program to send/receive data from a modem, I have written a program which can do this, however, if I read from the modem and there is no information in the buffer the program hangs until information is received in the buffer, I was just wondering if anyone knows how to set a timeout for the read command(read(fd,buf, 1);).
Thanks,
Rob.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Using this API offers other solutions such as WaitForSingleObject(), overlapped I/O, and multi-threading - these are described in the article at the above link.
Note also that Windows itself already supports modem communications using RAS for remote TCP/IP connections - this uses PPP to establish the connection.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi All,
I am writing a program to send/receive data from a modem, I have written a program which can do this, however, if I read from the modem and there is no information in the buffer the program hangs until information is received in the buffer, I was just wondering if anyone knows how to set a timeout for the read command(read(fd,buf, 1);).
Thanks,
Rob.
You might use SetCommTimeouts() ( http://msdn2.microsoft.com/en-us/library/aa363437.aspx ). I assume it will work even though you are using low-level I/O rather than Win32 I/O but if not you will have to use the Win32 comms API ( http://msdn2.microsoft.com/en-us/library/ms810467.aspx ).
Using this API offers other solutions such as WaitForSingleObject(), overlapped I/O, and multi-threading - these are described in the article at the above link.
Note also that Windows itself already supports modem communications using RAS for remote TCP/IP connections - this uses PPP to establish the connection.
Clifford