In article <(E-Mail Removed). com>,
(E-Mail Removed) (Harry) writes:
> I have an application where the client receives message from
> server,but the problem is i need to receive message till a particular
> string arrives in the stream the client is getting.Is it possible to
> use recv() systems call to do this or is there any other way.
Given a TCP/IP connection, recv() is the only way. Any routine that
appears to be otherwise is merely a wrapper around recv(). There is
no data sensitivity; the data is viewed as nothing more than a string
of bytes, and recv() gets as much as it can. If you're looking for
a particular string, there's not even a guarantee that one call to
recv() will even receive all of it. For instance, if you're looking
for "foo", the first time you call recv() you might just receive "fo".
The next time you call recv() there might be nothing ready, and the
third time you might finally receive the final "o" (plus any further
bytes which might be coming through).
So no, there is no simple solution. You'll have to write a routine
that's smart enough to concatenate chunks of data, while checking
whether the result contains what you're looking for. Take heart;
it's not as hard as it seems.
--
/~\
(E-Mail Removed)lid (Charlie Gibbs)
\ / I'm really at ac.dekanfrus if you read it the right way.
X Top-posted messages will probably be ignored. See RFC1855.
/ \ HTML will DEFINITELY be ignored. Join the ASCII ribbon campaign!