#### Archived

This topic is now archived and is closed to further replies.

# Just chars?

## Recommended Posts

way_out_west    122
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?

##### Share on other sites
MattB    122
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:

int someInteger = 5;send(mySocket, (char *)&someInteger, sizeof(someInteger), 0);