MFCAsync: Message-Oriented TCP and Multithreaded Client/Server

ID: Q192570


The information in this article applies to:


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:


MORE INFORMATION

The following file(s) are available for download from the Microsoft Software Library:

~ MFCAsync.exe
Release Date: 07-31-1998

For more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:
Q119591 How to Obtain Microsoft Support Files from Online Services
The flow of logic:

  1. AsyncServer listens on port 9898.


  2. AsyncClient spawns a thread, which connects to the AsyncServer.


  3. AsyncServer accepts the connection and spawns a thread to handle the socket communication.


  4. AsyncClient sends data packet to AsyncServer.


  5. AsyncServer receives and sends the same data packet back to AsyncClient.


  6. AsyncClient receives data packet, reverses the data packet and sends back to AsyncServer.


  7. Repeat steps 5 and 6 until being disconnected either by the AsyncClient or AsyncServer.


Steps to run the sample:

  1. Run AsyncServer.exe on machine A.


  2. Run AsyncClient.exe either on machine A or machine B.


  3. On the AsyncClient side, enter the server machine name where AsyncServer is running. Click Connect. Enter text in the Send edit box. Click Send.


  4. When you are done with the test, click Disconnect on the AsyncClient side.



REFERENCES

For more information, please see the following articles in the Microsoft Knowledge Base:

Q175668 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:
Q185728 SAMPLE: MFCSocs.exe Avoids Two Common MFC Socket Mistakes

Additional query words: CAsyncSocket multithreaded socket thread message


Keywords          : kbnetwork kbAPI kbMFC kbWinOS95 kbWinOS98 kbWinsock kbGrpNet 
Version           : WINNT:
Platform          : winnt 
Issue type        : 

Last Reviewed: July 21, 1999