Using C + + Builder to create online chat software-MyNetMeeting (1)


With the rapid development of Internet and local area networks and the popularity, more and more enterprises and schools have been built to connect the LAN and Internet. In the local area network or the Internet in very need some software to easily and quickly send information to achieve mutual and transmission of documents and other functions, we prepared this chat software - MyNetMeeting is used to meet this requirement. It's features include on-line chat or online meeting (NetMeeting), one to one real-time information exchange, and transfer files with each other.

1. Software analysis and design:

Now there are a lot of online chat software, such as popular now OICQ can easily achieve simple chat between two people, but more difficult to achieve in the local area network over a common communication that NetMeeting, even though there is also the Web through Internet chat rooms . This not only convenient (especially for a LAN in the same terms), but also expensive and poor security to such problems as sexual. Sometimes, for example, a company would like to open a conference on the Internet, if by Internet chat rooms, not only the high cost of Internet access, speed and slow, but also easy to leak trade secrets, not worth the candle. To address this situation, we designed this set of NetMeeting and Oicq-in-one software - MyNetMeeting.
This software can be online fast LAN communications, both cheaper and save time. And the server is running in the local area network in the local PC, safe and easy management, and fast, convenient and reliable. Server can run in the local area network in the normal PC machines, no special server, so it can greatly reduce costs, but also simple, and do not make the required background database. But if necessary, can also be very convenient to achieve back-end database support.

2. Software architecture:

We do chat software, including server-side part and the client part. Server-side includes three parts, the meeting content, online nickname, online user's address. When using the chat software, first for a server, the server took land on the user's nickname and address of the register down, so you can easily monitor and manage online.



Client consists of three parts: first, online meetings; second, private chat room; third, to send the file. There is also the right of the list of online users list all users currently online. The following statement when the input box, enter the information to be sent.



3. Software functions and features:

1. Online chat and online meeting (NetMeeting)
As shown on the right, on-line to the realization of the function is more than one person, in conjunction with real-time online meetings, so the information of a human hair can be seen all online users (similar to chat rooms). Upper left of the Memo on a shelf in the substance (what time, who said anything), there is a system information (who joined the meeting, or who withdrew from the meeting, etc.). Just right-click the location where the blank, by connection to the server, you can connect to the server where to chat and meetings; by the font color can change the font according to their color preferences; according to show / hide online users, we can Online user list on the right show or hide. Memo lower left that you want to send the message, in the box marked to say, by sending or shortcut key Alt + S to be the message sent. The right is a list of online users at any time can see a list of online users. (If you want to send personal information or transfer files on a user list, right mouse click pop-up menu, choose to send messages or transfer files).



2. Private Chat Space
Private chat room is used for online users to send messages between one to one (other people can not receive).

To whisper, the first online user list, select the object you whisper, double-click the left mouse button, then left the label will show the object of your choice whisper (right in the whisper target laixh). That you can individually with the object of your choice to send private chat messages, whisper friends. Specific operations and on-line meetings as the same operation.

3. Transfer files
If you want to transfer files, you can send files to this page first point, then the right of the list, select the file you want to send to the online user, the same, "Send files to:" followed by the label will show the user, then use Browse to select the file transfer (you can also direct the path of the file and the file input into), then send the file can be sent to your selected users.



4. Software realization

1. Software platform: Windows98 + Borland C + + Builder5.0

2. Send and receive files in the realization of the flow of data, I use the Builder inside NerMasters controls NMStrm and NMStrmServ two controls. NMStrm control is based on TCP / IP flow control. It can receive streaming data, then the network sends to the server. This control includes a number of methods and properties, for example, set the data source. NMStrmServ control can receive from the client to send to the data stream. Streaming server is only listening TCP / IP port, is not responsible for monitoring UDP port, the default port number is 6771. To send the file stream data, simply call NMStrm control to PostIt method. When a stream of data sent to the server, trigger NMStrmAerv control to OnMsg event, this event handler can be completed document to display the work.

3. WinSock is a set of written using C language API, used for data transmission through the Internet. Available through the WinSock programming flexibility. Write WinSock application could have been a lot of trouble, but in C + + Builder 5.0, you do not need direct and WinSock in the API deal with, because the C + + Builder 5.0 newly added TClientSocket control and TserverSocket control, the two control encapsulates Windows of the API, allows access to the WinSock greatly simplified. Socket connection is established with the establishment of the TCP / IP protocol based on, but also support other related protocols such as XNS, DECnet, and IPX / SPX, etc.. Socket connection must be established with a server-side (Server) and a client (Client). In C + + Builder 5.0, respectively, control and use TClientSocket TServerSocket controls to manipulate client and server-side Socket Socket connection and communication. The two controls used to manage server and client connections, which in itself is not Socket object Socket object manipulation is TCustomWinSocket its derived classes, such as TClientWinSocket, TserverWinSocket. TServerClientWinSocket so.

Socket connections can be divided into three types: client connections, monitor connections, and server-side connection, the so-called client-side connection is made by the client of the Socket connection request, the goal is to connect the server side of the Socket. To this end, the client's Socket must first describe it to connect to the server Socket (mainly refers to the server Socket address and port number), and then positioning to be connected to the server Socket, found later on to the server Socket request connection . Of course, the server side at this time may not be exactly Socket state is ready, however, the Socket server will automatically maintain customer requests connection queue, and then, when it deems appropriate to the client Socket issue "allow connection" (Accept) of signal, then the client and server-side Socket Socket connection is established. The so-called listening for connections, server-side Socket not locate a specific client Socket, but is waiting to connect status. When the server-side Socket listen to or received by the client Socket connection request, it will respond to the request of the client Socket Socket handle to create a new connection with the client, and server-side Socket continue in monitoring the state can also receive Socket connection to other client requests. The so-called server-side connections, when a server receives a client Socket Socket connection request, put a description of the server to the client Socket, once the client to confirm this description, the connection is established. In this article, the chat program is listening for connections with that server settings after the number of monitor connection, the client connection on the server side, so that you can communicate with each other up.