Program Implementation function:
LAN chat software, start to find online devices, and can carry out simple text chat.
In fact, the following diagram has explained the most functional principles of the program.
Program diagram of Core class
I think the best technique to use in this program is IOCP. In the back I will write a blog for IOCP, this technology although just learned a bit messy, but it is very useful.
The event completion in the middle of the udpserver thread in the above diagram is the event that the Mainserver thread sets after the Listen function call ends. I forgot to mark it here.
Description
A few days ago in the laboratory to see "Windows Network and Communication program design" this book, after reading the first 5 chapters, I feel that the current technology to do a LAN chat software should be almost. Although there are a lot of details of things are not very understand, but to do a small size of software, I think it is not a problem. In this way, after about 4 days, that is, 18th this month, this Lanchat program was born ~
First of all, I declare: because I first write network-related programs, so there must be negligence, in the relevant aspects must be a lot of bugs, in addition, I often encountered in the test when the failure of the program startup, and the reason has not been identified. So I don't guarantee the stability and security of this program. (as the designer of this program is really ashamed ~ will be good later)
Another code in the large analysis of the structure function, after all, the initial realization of the time is not clear to realize and its function, so there is no scruple to release this piece of resources. For example, the chat window creates this piece and I don't use delete.
The multithreading section involves access to the data, so I use the key segment: CriticalSection structure and related functions.
Because this document is written in the bedroom, there is no online device, can not open the Chat window, in the lab three computers between the use of no problem.
In addition, Winsock2 initialization is selected in the project, in the console class, such as the application of the socket program must be done before the relevant initialization and library, file contains work.
Socket use program first attempt.