Converting and reading data from winsock2 recv buffer

Hey All,

First post, and yes I searched but couldn't find anything that gives some specifics.

I've built an app that calls a specific php file on my server and returns that data in the recv() function of a socket request.

The php script simply returns either Valid, Invalid, or Unknown based on the license info I pass to it, so my buffer contains the headers, a line break and then simply one of the afore mentioned words.

Can someone please tell me a simple way to ignore all the header info and just grab the one word from my buffer?

This is my first real C++ adventure so please go easy on me.

Thanks in advance for any assistance.

Tai
You probably are reading the data into a character array. If so, I would copy the array to a std:string, then parse out the data. In parsing, you could use one of the std::string find() functions for the newline, then create another string by callilng substr().
Perfect ..... thanks so much, that was a lot easier than I thought it would be :)

1
2
3
4
std::string response = outbuff;
size_t position = response.find  ("Success");
if (position != string::npos) auth = true;
return 0;


Appreciate the help alot!

Tai
Last edited on
Topic archived. No new replies allowed.