Quote:
Originally Posted by mac11
You can send and receive any data you want. You just need to set up a system such that the sender and receiver know what is coming through the socket.
So if you send an int the receiver needs to know that the thing he just received is an int and not 4 chars (for example)
Does this help? I'm not sure how much help you need and I don't want to type for 20 minutes if you only need 3 minutes worth of help (laziness factor!)
This answer help me a little bit. But I still have a (small?) problem. For example I tried this:
Client:
-
struct CommandData
-
{
-
int Test1;
-
int Test2;
-
char *Para;
-
};
-
-
CommandData Test;
-
Test.Test1 = 10;
-
Test.Test2 = 33924823;
-
Test.Para = "Hello World!";
-
-
send( Socket, (char *) &Test, sizeof( CommandData ), 0 );
-
Server:
-
struct CommandData
-
{
-
int Test1;
-
int Test2;
-
char *Para;
-
};
-
-
CommandData Test;
-
recv( connectedSocket,(char * ) &Test, 256,0 ); // Whats about the Number 256? What I need to put there?
-
-
printf( "Received:%s-%i-%i\n", Test.Para, Test.Test1, Test.Test2 ); // Output "Received:-10-33924823"
-
Firstly, is this the right way to do this? I'm very frigthend that I maybe receive not all data. And the struct can't be used.
Another problem is that I don't receive the "char *Para". How I send it on the right way? And how portable is this?
Example:
Server Windows - Client Linux System
What will happen? Does it still work?
Thanks for your help :)