Very early want to do a similar QQ chat program, suffering has been no time, coupled with the feeling that the network more difficult to do communication, so this idea put aside. The last two months of school holiday idle looked at some TCP/IP, multi-threaded books, plus the previous point of C + + and VC Foundation, began to do it, a total of 17 days to complete the program. It includes server-side program Netmsgserver and client program netmsgclient. Through programming also found that the original socket (like SEND,RECV, etc.) command than VC encapsulation good cscoket faster. How to say, the program is not small, there are more than 3,000 lines of code, error and garbage code is certainly not a lot of, after all, the level is limited, we see do not throw eggs on the thank you.
I. Description
This program uses TCP/IP socket multithreading programming, and some important synchronization operations do a time-out control to reduce the waiting time, like connecting the server, waiting for the other party to receive files. Basic skills can be similar to QQ, can do a lot of chat and point-to-point file transfer. The advantage of this programming is that the data will not be lost, and the user can immediately respond to the online offline. The only regret is that the interface to do too much, I am ignorant of the interface programming, but also can only be used in the LAN, because there is no increase in the function through the proxy server.
Two, probably communication flow
1, Netmsgserver server side
It employs two threads, one of which handles connection requests for each client (accept), and another that handles received commands and returns information after the client requests a successful connection, including user registration, landing, offline, generating online user lists, querying for changes to an online user's information, and so on.