After using a few years of QQ, suddenly I want to be a similar chat tool, so I have the idea of designing a network instant messaging tool. Write the initial idea here for yourself and others. I am absolutely not an authority, but I can write some practical things for everyone to share, and it is also a pleasure. I hope all those who have read this article can let me know your thoughts and help me improve.
Some of the instant messaging software
First, the choice of communication protocol
First analyze the communication protocols whose network communications should be selected. Currently, protocols for data transfer are available for us to choose from: TCP protocols and UDP protocols.
The advantages and disadvantages of the two are as follows:
TCP protocol: Connected transport protocols, establish a stable link between the transmitted data when transmitting data. Suitable for transporting data as possible in an unreliable network environment. TCP is designed to dynamically meet the requirements of the Internet, and it is enough to make a lot of mistakes. Insufficient is that the establishment of the edge takes longer and may delay or interrupt the entire transfer due to accidental loss of packets.
UDP protocol: UPD (User Data Protocol). Non-connected transport protocol. UDP provides an application for the application of the original IP datagram to send the package, and does not need to establish a connection when sending. This does not need to establish a connection time. There are a number of requests and a responding customer - server application uses UDP, which avoids the trouble of establishing and releasing the connection.
In the integrated, in the variety of this chat software, there is a total of the following network protocols that need to be used:
l send and receive information
l Send video and audio live
l Send a file
When sending information, the sender directly sends a UDP packet, and the recipient keeps listening to the UDP packet. This is very convenient. When transmitting video and audio information, there is a high demand for transmission speed; however, when viewing and listening to the program in a fast multimedia stream, it is occasionally lacking a frame or several frames, and it will not be perceived by the audience. Therefore, when transmitting video and audio programs, it is best to use a UDP protocol. When sending a file, the quality of file transfer has a considerable requirement, which is not allowed to lack any data due to network transmission causes or other reasons. At this time, we need to establish a way to transfer as stable as possible, then Select the TCP protocol.
Second, the selection of databases and languages
First look at the database, what we need is a very safe and reusable database service. To do this, let's choose a database server, here I choose Microsoft SQL Server 2000. In the future, all data services will be used. Of course, this choice is only the preferences of the author, and there can be more popular, other data servers, such as Oracle, MySQL, etc.
Just use the language, now we can choose from: MFC, C #, VB, Java Delphi. As for which one to choose, it can be determined from different needs and personal preferences. If you want to do large business development, naturally use MFC better because the program is highly performed, and the performance is stable. It is easy to make a unified installation document, which is conducive to commercial publishing and release. C # with Java is not so easy, because they all need to pre-install a running environment on the client, which has become the biggest difficulty in the promotion of the program written in these two languages. But they are more convenient than MFC, and it is more convenient to use, so it is more suitable for personal research. In the end, I chose C #. Because I don't know anything about C # before making this procedure, I also want to learn this software by studying this software to learn a step C #.
Third, the function list of this software
Here is the initial idea of all the features of this software.
l Register a user L user login
l Modify user information
l Modify password
l Add a friend
l Delete friends
l Send / receive information
Next, I will explain the implementation of each function, and the details of the specific implementation will be explained in future articles.
Registered User: This feature will complete the work of registering a new account. Because all account information is stored in a data table, because the task is completed, only one plug-in command to the database is required.
User login: Verify that the username and password in the database server match, if matching the username is passed to the next page to deal with, if not match, the prompt is incorrect, and the prompt is incorrectly, and the re-enter.
Modify User Information: Complete a database modification work. The user name and password are required to modify the data after verification.
Change password: You should enter the username and the original user password before modifying. The verification can be modified.
Add a friend: Do not discuss the issuance of sending user requests first, we only consider the most ideal state, namely, add a friend, then the friend is directly added to the friends list, at the same time, this user is also joined by friends a list of friends in.
Delete friends: Do not discuss more complicated situations here, just consider the ideal situation, that is, when you delete your own friends, your friends disappeared from their own list, while you automatically remove from the other's friends.
Send / Receive Message: Since the system is in the blocking state when listening to the UDP packet, the listening data must be processed into a separate thread, otherwise it will not be able to do anything else while listening to UDP. When sending a message, we should be divided into two cases. The first case is the other party online. At this time, only the data packet containing the message will only be sent to the other party's IP and the specified port. The second case is that the other party is not online. Here we need to save the message on the server side, when the other party is online, uniformly download the other party's client. The reception message is relatively simple, as long as it is separately opened, the loop listening network can be used.
The above is the analysis and understanding of the software that will be developed, it is still very uncomfortable, but with the progress of the in-depth and engineering progress, it will be further improved.
references:
Computer Network Third Edition Andrew S. TANENBAUM Beijing. Tsinghua University Press