This article describes streaming Sockets, one of the two available Windows Sockets types. (Another type is the data PACKET socket .)
Stream sockets provide data streams without record boundaries: they can be two-way byte streams (applications are full duplex: they can be transmitted and received simultaneously through sockets ). It can transmit ordered and non-repeated data depending on the stream. ("Ordered" means that data packets are delivered in the order of sending. "Not repeated" means that a specific data packet can be obtained only once .) This ensures that a stream message is received, and the stream is very suitable for processing a large amount of data.
The network transmission layer can split or group data into several appropriate data packets.CSocketClass will handle the package and package for you.
Stream is based on explicit connection: socket A requests establish A connection with socket B, and socket B accepts or rejects the connection request.
The call process is very similar to the stream: Normally, the order in which the recipient hears you is the same as that in your speech. There are no duplicates or omissions. Streaming sockets are suitable for File Transfer Protocol (FTP), which facilitates transmission of ASCII or binary files of any size.
If the data must be delivered and the data size is large, the streaming socket is superior to the data PACKET socket. For more information about streaming Sockets, see the Windows Sockets specification. This specification can be obtained in Platform SDK.
Both the demo CHATTER and CHATSRVR of MFC use streaming sockets. These examples may have been designed to broadcast data packets to all receiving sockets on the network. The current design is better because:
- Broadcast models are subject to network flood (or storm) problems.
- Later, the client-server model was more effective.
- The stream model provides reliable data transmission, while the data reporting model does not.
- The final model is used inCArchiveClass lendingCSocketClass Unicode and ANSI Socket Application communication capabilities.
Note:If you useCSocketClass, you must use a stream. If you specify the socket typeSOCK_DGRAM.