[En-Nut-Discussion] Empty a stream

Marc Wetzel mwse at gmx.de
Mon Nov 11 20:53:50 CET 2002


NutIfStreamFlush(NUTDEVICE *dev);  // flushes output, not wanted here...

But whats about this:

/*!
 * \brief Read from a stream device.
 *
 * \param dev  Identifies the device to read from. This pointer
 *             must have been retrieved by calling NutDeviceOpen().
 * \param data Pointer to the buffer that receives the data. Set to
<==
 *             null to flush the input buffer.
 * \param size Size of the buffer. Ignored if the data pointer is
 *             null.
 *
 * \return The number of bytes read, 0 on timeouts and broken
 *         connections or -1 in case of an error.
 */
int NutIfStreamRead(NUTDEVICE *dev, char *data, int size)

-> NutIfStreamRead(yourdevice,0,0); 


Greetings,
Marc Wetzel



-----Original Message-----
From: en-nut-discussion-admin at egnite.de
[mailto:en-nut-discussion-admin at egnite.de] On Behalf Of Mikael
E.Pedersen (MEP)
Sent: Montag, 11. November 2002 14:56
To: en-nut-discussion at egnite.de
Subject: [En-Nut-Discussion] Empty a stream

Hi.

I am trying to write a small POP3 client for Ethernut, but i am having a
problem:
I want to get rid of any incoming data from a TCP stream, before i send
a
command to the server.
I have tried this:

while(NutDeviceGetLine(sostream, buffer, sizeof(buffer)-1) > 0);

But when the stream is empty, it just sits and wait for more data (that
never arrives).
Can i empty the stream in some other way? And if so: How?
Or should i rather split my program into two seperate threads. One that
transmit commands, and one that listens for the response?

Best regards,
Mikael

_______________________________________________
En-Nut-Discussion mailing list
En-Nut-Discussion at egnite.de
http://www.egnite.de/mailman/listinfo/en-nut-discussion




More information about the En-Nut-Discussion mailing list