Windows Sockets: streaming socket

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.