I was thinking by using Socket to do chat room programs ...

zhaozj2021-02-11  199

A very early article is written when I started Winsocket. How to use Winsocket is not talking about how Winsocket is just a very simple program. Suitable for our rookies to see;)

Beginner Winsocket, I have seen several articles that have not been seen from the Internet. It is affected by the purity, and I wrote this small chat software while learning. Because it is used by the CSocket class, it is uses the TCP / IP protocol, so it can be used between the TCP / IP service protocol and Unicom, such as the local area network, Internet network - I haven't tried it, it should be ).

The program is actually not difficult, but I caught some ideas, and I will share it with you! Since the two machines can send information to each other, if so, if you implement the function of switching, screen graphics, etc. in the client program. Then determine the information of the Server party at any time, and perform the corresponding action after receiving the specified information. Such as: Sever said to the client: "Dear shutdown" and then the Client party receives the message, judge! in case

Server is said to "dear shutdown", then it is -> shutdown. Such as this, you can just have a client program to be hidden like Bo or Neyspy.

Everyone is chatting online with OICQ or ICQ! Mi 2 :) Suddenly, I can do it. If you take time to improve it, the client wants some modifications. In addition to adding a TreeCtrl used to display a list of friends on the line. Then, as SERVER, it is judged whether to send information, and then add a feature in the sending information, or send it to the server, Server, oh! Give a certain, ok. Then send this information to a certain. And Server should join the operation of the database, first record all users, record online users, list the friends list of this ID according to the ID of the user just launched, and forward the online filtering into this user Inform the list of friends online.

Calling ~~~ One breath is so much tired of me. If you look carefully, add your questions about Winsock. I will feel that it is not difficult to do an OICQ! Ha, it is not easy to do a perfect OICQ Like, it is not easy to consider a lot, such as network clogging and other conditions. However, after the basic truth understanding, plus CSocket is so convenient, we can also make our own chat room! ! !

In fact, I want to be a true Dongdong that can use OICQ Like. It can be limited, and the WINSOCK time is not long. So you can find the same way and the buddies is the best, if you see this and if you are interested

E-mail! My thoughts are only included in programmers, all users are classified, divided by Delphi, VC, VB. You can then view all registered programmer list, which makes Programmer to communicate more conveniently, isn't it. There are also some new features, you must let our most creative OICQ Like, the most creative OICQ Like like Half of Life is better than Quake.

Give the download:

Server 44K

Client 36K

Next day ...

Inadvertently seeing an article on how to do chat room on BBS. Looking at it carefully and found that my thoughts were basically consistent, and of course, he described more detailed.

Dare to enjoy exclusive, special adhesion to share with you:

The role of the server side in the program.

From the icon, there is no direct communication between the two Winsock controls of the server side, while SckServer1 and Sckclient2 and SckServer2 and Sckclient1 cannot communicate directly. This is, if SCKCLIENT1 issues information to SCKClient2, the information is first accepted by SckServer1, and SckServer1 will pass the information to the program.

The information processing section, the information processing section will pass the handled information to SCKSERVER2, and then pass it by SCKS ERVER2 to SCKCLIENT2. vice versa. Then the server side information

What is the processing part?

1. Do some limits the number of channels.

2. Passages that have been closed after use, must be reused to save resources.

3. Must make different processing on the transmitted packet information to make different processing. Different information can be distinguished by unlocked the header of the data.

There are two ways to chat online: the first, in a broadcast method; second, a point-to-point manner. Broadcasting methods, all customers can receive information from a customer. Point-to-point's way, I want to say "whisper", a pair of customers specializes in a conversation "small house", other customers can't "listen" to their conversation. The header of point-to-point mode data is "PT", and the broadcast mode has no header.

转载请注明原文地址:https://www.9cbs.com/read-5076.html

New Post(0)