Netmsg LAN Chat Program

Source: Internet
Author: User
Tags socket

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.

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.