Receives data until either the provided string is found or the request times out based on the nTimeout property setting.

This method is very useful for long data streams that usually would require multiple Receive() requests. Since TCP/IP buffering determines how much data Receive() returns retrieving large data streams or data when the connection is bad usually requires a loop. Using this method avoids writing the loop syntax in your application code and wraps this functionality into this method.


Return Value

Data containing search string


The string to search for in the result.

Size of the Receive buffer.
Defaults to nBufferSize


Internally several Receive() calls may be made in order to retrieve the data. If the data stream is constant (IOW the data doesn't stop coming and the search string is not found) no timeout will occur. A timeout occurs only if the data flow stops and the string requested is not found. It's recommended you set the timeout to a relatively short interval for this operation if there's a chance the data might not be found to avoid long waits when the data flow stops.

Data may not be terminated the search string - it's just guaranteed that the data is in there. Check nError for any error conditions like timeouts or that the searchstring was not found.

A good example of usage for Receive() and WaitFor() is provided in the wwPop3 class.


oIP = CREATEOBJECT("wwSocket")

oIP.Send("LIST" + CRLF)
lcResult = oIP.WaitFor("." + CRLF)

IF oIP.nError # 0
   ? "The request timed out..."

? lcResult

See also:

Class wwsocket | wwsocket::nBufferSize | wwsocket::Receive

© West Wind Technologies, 1996-2024 • Updated: 11/13/01
Comment or report problem with topic