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