Hi.

I am studying networking programming from Network Programming For Microsoft Windows, Second Edition by Anthony Jones and Jim Ohlund. I am just about ready to start on a new product that will be my first real Winsock program. I want to design and implement a simple message program (chat) that work over the IP protocol and TCP protocol.

I have the basic program core design in my mind. However, I am stuck with one problem and it is a problem that even Jones and Ohlund implied could be difficult to overcome for inexperience network programmers.

How do you predetermine the size of the data you receive?

Winsock has two basic functions for receiving data: revc (IPv4 or Winsock 1.1+) and WSARecv (IPv6 or Winsock 2). WSARecv is a powerful tool for *predetermined* data size. You can send multiple packages at one time, but the data size must be predetermined (i.e. 10k, 20k, and finally 30k). I will probably use revc since it is more flexible. Even with recv, however, you must give a specific size (byte) to read. Jones and Ohlund recommend sends the size of the data in the first four byte of the data stream. However, what if the user wants to send something that is larger than what a bour byte char variable can hold?

Please post any possible solutions.

Thanks,
Kuphryn