From: Tomi Manninen OH2BNS (cpfni.dxrrxywpv@mx.dy.fi)
Date: Thu Jul 19 2001 - 10:01:07 EEST
On Wed, 18 Jul 2001, Dustin Moore wrote:
> Ok, how do I know when to issue a read? It seems like if I issue reads
> constantly this will bog down the system. So far I envision::
> while (1) {
> read(0,very_large_buf_,sizeof(very_large_buf));
> /* Do work on buffer */
>
> }
This will stop and wait at read() and continue execution of your program
when a packet arrives. If that is ok (it often is) then it's the
easiest solution.
If on the other hand you have input from many sources or if you need to do
stuff triggered by other events than a received packet, then you need to
acquaint yourself with blocking/non-blocking reads, the select and/or poll
system call, timers, signals etc. depending on what you are doing.
> Also, if I read past where the fragment ends it seems to be that I will
> get garbage. How do I know where the fragment ended?
Read will return with the length of the received packet.
-- Tomi Manninen Internet: terhi.victor@logonet.com OH2BNS AX.25: terhi.victor@logonet.com KP20ME04 Amprnet: tnk.xiwliejxgj@tnpop.net- To unsubscribe from this list: send the line "unsubscribe linux-hams" in the body of a message to uizlhun@kitanet.ne.jp
This archive was generated by hypermail 2b30 : Thu Jul 19 2001 - 10:16:22 EEST