I’m fairly new to c++ programming. I am trying to code a windows client that communicates to a linux server. That part I have successfully done.
Now I don’t know what to do to continue this.
This is what I need to do (but dont know how to).
Now my client asks for 3 stuff.
Example
declared client variables 1,2,3 as string...
Enter Anything: dgasggfds
//dgasggfds is now stored to cvariable1
Enter Anything again: zxcasd
//zxcasd is now stored to cvariable2
Enter Anything again again: qwert
//qwer is now stored to cvariable3
Now the client should send each of this variable to the server.
The server will then also use those variables and execute its codes.
So now on the server
cvariable1 is now svariable1 on the server.
cvariable2 is now svariable2 on the server.
cvariable3 is now svariable3 on the server.
Once all the variable is there, it will execute a code.
Please advice. Thanks.
–edit–
I tried using send() recv() it works but I can only send 1 variable.
and I dont know how to set the recv data into a variable on the server.
–edit–
I kinda get how to save the recv data into a variable.
But still don’t know how to do it with the multiple data.
Also the 3 variables must always be together. they cant be separated.
The servers code needs those 3 variables/data to execute the cmds properly.
–edit–
Does this make any sense?
string* packet = new string[3];
packet[0] = 'var1';
packet[1] = 'var2';
packet[2] = 'var3';
//send request
if (send(sock, packet.c_str(), packet.length(), 0) != request.length())
die_with_wserror("send() sent a different number of bytes than expected");
Its giving me some error though. packet:expression must have class type.
What I’m trying to do now is send it in an array, and break down the array once on the server, is this logic okay?
On client side concatenate the three variables using a special character to separate them, e.g.
and send sending
On server side
you will have your data in incoming_data_buffer. Now split incoming_data_buffer using “_”, you will have your 3 variables.