Quote Originally Posted by jamesford View Post
Yes you're right, it works with %d and not %s, though I don't understand why, as s->filename is a char* ...
Anyway, you're right, they don't give the same result : the client returns 4 but the server returns 1...
It seems you found out the problem. Can you explain it to me now ?
DAMN I'm good .
There's a lot more wrong with your code, though, so you should fix a lot. Eg. check the recv/send return codes and whatnot. Also, reading directly to a struct and sending from a struct is actually kind of wrong, though used very often.

Anyways, the problem in this case... You send the data from the structure and you read it into the other structure. This means both structures must have EXACTLY the same format in both client and server. But apparently it does not: the relative address in one is 4 and in the other 1.
So the problem is the classes aren't the same. This can have two reasons I can think of. First, it might mean the structure "REQUEST" aren't identical in client and server. In that case, obviously, you can't copy it verbatim. You can test this by printing sizeof(REQUEST) in both client and server. If they're different, then the REQUEST structures are different.
It might also mean the client and server are set to pack the structures differently. See, a structure with one char might be padded by 3 useless bytes to speed up the processing at the cost of memory. But it might be configured not to add this padding at one, and add it at the other.
How you configure this "packing" depends on the compiler and I never do it, so I'm not sure how it's done (I refuse to use these details in my application). What compiler are you using?
Look if one of the programs has something like "#pragma pack" or similar.

And how the line works... It's prints the integer value of the pointer should the entire structure be at address 0. Actually printf with "%p" was probably better, but this was easier for me.