Message-Oriented TCP and Multithreaded Client/Server
Article ID: 192570
Article Last Modified on 11/21/2006
APPLIES TO
- Microsoft Foundation Class Library 4.2
This article was previously published under Q192570
SUMMARY
MFCAsync.exe contains a Visual C++ 5.0 project sample that
shows the communication techniques between a client (AsyncClient) and a server
(AsyncServer) application using MFC CAsyncSocket class on each sides.
Here are some highlights of this sample:
- MFCAsync.exe follows KB article
175668, showing the use of Transmission Control
Protocol (TCP) socket communication in a separate thread other than the
Graphics User Interface (GUI) thread; as such, the blocking of the GUI message
pump does not affect the delivery of socket messages. Multiple instances of
AsyncClient can talk to the same instance of AsyncServer.
- MFCAsync.exe also complies with KB Article
185728 in issuing of socket Send and Receive calls.
- MFCAsync.exe adds message boundary on top of the
stream-oriented TCP. Each message is sent with a 4-byte-length packet header
followed by the body of the message. Users can append more customized packet
header fields to this length field.
REFERENCES
For more information, please see the following articles in
the Microsoft Knowledge Base:
175668
FILE: MultiSoc: Illustrates Using Sockets in Multiple Threads
For more information about downloading files from the Microsoft
Software Library, please see the following article in the Microsoft Knowledge
Base:
185728
SAMPLE: MFCSocs.exe Avoids Two Common MFC Socket Mistakes
Additional query words: CAsyncSocket multithreaded socket thread
message
Keywords: kbdownload kbapi kbfile kbinfo kbnetwork kbwinsock KB192570