How does winsocket LAN chat software run?

Source: Internet
Author: User

How does winsocket LAN chat software run?

Program implementation functions:

The LAN chat software can be started to find online devices and chat with simple text.

In fact, the following figure shows the vast majority of functional principles of the program.

Program diagram of the core class

I think the best technology used in this program should be IOCP. I will write a blog post on IOCP later. Although this technology is a little messy, it is really useful.

In the preceding figure, the UDPServer thread waits for the event to be completed, which is the event set by the MainServer thread after the Listen function call is completed. I forgot to mark it here.

  Description

I read the book "Windows network and communication program design" in the lab a few days ago. After reading the first five chapters, I feel that the technology at hand should be similar to making a LAN chat software. Although there are still a lot of detailed things that I don't know very well, I think it is not a big problem to build a small-scale software. In this way, about four days later, that is, on the 18 th of this month, this LANChat program was born ~

First, I declare: Because I wrote network-related programs for the first time, there must be negligence and there must be many bugs in related aspects, in addition, I often encounter program startup failures during testing, and the cause has not been identified. Therefore, I do not guarantee the stability and security of this program. (I feel ashamed to be the designer of this program ~ Will be fine in the future)

In addition, in the Code, most of the analysis constructor functions are the same as virtual functions. After all, it is not clear that they can be implemented at the beginning, so there is no scruple about releasing resources. For example, I didn't use delete to create this part in the chat window.

Multithreading involves data access, so I use the key section: CriticalSection structure and related functions.

This document is written in the dormitory, so there is no online device and the chat window cannot be opened. It is okay to use it between three computers in the lab.

In addition, winsock2 Initialization is selected in the project. before using the socket program in a console-class program, you must perform related initialization and libraries and file inclusion.

The first attempt of the socket application.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.