Sending other datatypes
Hey! I see that declaration of the send() function is
so I can send only char*s, but what to do if I want to send other variables or datatypes? Example:
int PASCAL FAR send ( SOCKET s, const char FAR * buf, int len, int flags )
Now, how do I send aObject? Also, how to receive it?
> so I can send only char*s,
No, you can send any contiguous block of data you like. It's just your compiler writer hasn't gotten round to changing it to void*
> but what to do if I want to send other variables or datatypes?
Well you can send an int, but you'll have to contend with an endian problem at some point.
Most people use htonl() and ntohl() to ensure that the result is consistent.
As for your string, I'm guessing that's an object with way too much system specific information (and no doubt a hidden pointer or two).
For this, you need to extract the proper string, send that and recreate your string object at the other end.
Uhh, a lot of fuss, guess I'll have to make one LONG string and send it over. However, thanks for the reply. Maybe others could advise something? Like solutions or different APIs? (if there are any)
All of them are C++.