Originally Posted by
Pikmeir
secondaryFunction() only acts as a middleman, and nothing else. When it receives 'buffer', it will just call another function (I wrote some other functions in another file, but I'm not using them yet).
For example, (I'm sure you already understand) if the client types 'say hello' it will send this as buffer to the server, the server will send it to secondaryCommand(), and secondaryCommand() will change it to a string and send it to another function that examines it, that other function will choose the reply and then send the reply to the main function to go to the client.
Ah. In that case, I'll just tell you that the problem is that you are passing the string by value. You want to pass by reference:
Code:
int secondaryCommand(string& sString)
{
cout << sString << endl; // just a temporary code to check and see if the Server can manipulate the data
sString = "If you see this message on the client, then everything works!";
return 0;
}
You need to be clear: are you using the std::string object or the char[1024] buffer? You have to pick one, not both, or you will only confuse yourself.
Originally Posted by
Pikmeir
If so, what do I have to do to get this function to send my string 'sString'?
Something like this:
Code:
if ((bytecount = send(*csock, &sString[0], sString.length(), 0)) == SOCKET_ERROR) {