Winsock Network Communications I hope to explore the program of Winsock online communication. Due to the popularity of the Internet, more and more programs have functions that communicate online with other programs. In fact, all these features are built on the Winsock interface, The application executing most of the basic objects of most network communication is called a socket or Soft socket. Adding a network communication function using the MFC Winsocket class is relatively easy. Basic class CasyncSocket provides comprehensive Socket communication capabilities that are driven by events, you can Create your own Socket class to capture and respond to each event. I suggest you first take the CasyncSocket class. An example of a program communication: First, some event notification functions in the CasyncSocket class can be called.
On the onaccept listener calls this function table The other party's connection request is waiting to accept OnClose to indicate the other end program of the connection. Onconnect means that the connection to the other end program has been completed .onoutofbandData indicates that the overrecept is connected to the data connected via the Socket connection. I have received OnSend indicates that the Socket is ready to send data. This example is to derive a class CMYSocket, which is desirable to capture activated events by overwriting the above notification function. Perform the corresponding operations in the parent dialog box. Specific Operation can see the code downloaded by this site. After compiling, you can launch two copies of the program, one in the Server side, one in the client, first set the listening mode in the server side, then connect to the Client side, these two programs can be send each other information, and look a lot like ICQ author:! Zhu Rights Reserved Download this sample code (20k)