Just chars?
I''m slowly beginning to understand what and how sockets work.
There is just one question that I really need to ask.
Winsock... if I''m using the TCP/IP protocol suite, does that mean that I can only evcer send and recieve characters.
I mean, what about floats? And what if I wanted to send a bool?
Am I restricted to using chars and their ASCII codes to determine if they are integer values?
No, you can send and receive anything you''d like. Reading and writing to a socket is a bit like reading and writing from a file. The socket is analogous to a file handle.
The send() and recv() functions take a char pointer, but you can cast the data you wish to send. For example:
The send() and recv() functions take a char pointer, but you can cast the data you wish to send. For example:
int someInteger = 5;send(mySocket, (char *)&someInteger, sizeof(someInteger), 0);
Right. Think of the data as an array of bytes rather than an array of characters (a char is effectively a byte; sizeof(char) == sizeof(byte)). Since every possible data type is composed of bytes/chars, you have the ability to send any data type over a socket by casting, as MattB showed.
RapscallionGL - arriving soon.
RapscallionGL - arriving soon.
________________________________________________"Optimal decisions, once made, do not need to be changed." - Robert Sedgewick, Algorithms in C
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement