CSocket must use stream socket to not be able to use datagram socket

Source: Internet
Author: User

If you use the MFC socket Class Csoket communication, you must use a stream socket and not be able to use the sock_dgram type socket. The reasons are as follows:

The difference between a 1 stream socket and a datagram socket is that

The former is reliably transmitted, and data is split into multiple packets sent:

(1) Send and receive packets on both ends of the packet in the same order.

(2) The packet cannot be duplicated.

(3) Each packet has no bounds.

The latter is exactly the opposite.

2 CSocket through the CArchive to read and write data from the socket. The main principle is to create a csocketfile associated with CSocket

The CArchive object that reads and writes data from the CSocketFile object. CArchive Read and write data is read and written in binary format, its characteristics

Exactly matches the stream socket.

Add:

The title comes from the MSDN documentation for Windows Sockets:stream Sockets last Word, url: https://msdn.microsoft.com/en-us/library/474e45z0.aspx.

For specific instructions, refer to the articles in the CArchive class and MSDN documentation for Windows Sockets:using Sockets with Archives

Note in 2nd of the CSocket pragramming model title.

CSocket must use stream socket to not be able to use datagram socket

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.