Chat Application

Chat-Application

A chat application allows users to interact or communicate by texting, audio, and video. It can be useful for social or commercial activities.

In this assignment, students are required to write a Chat Program based on Windows Socket Programming C++. The program should allow users to chat concurrently on the Internet (i.e., User A can send encrypted messages to User B, and vice versa). You can download the sample programs (namely, “server.cpp” and “client.cpp”) from the Web site. The program should consist of the following modules:

  1. User management: provide functions to add, delete, or group users;
  2. Group chat: allow users to chat as a group;
  3. Management of connections: support at least three concurrent connections.

User Management: Implemented By Server

  • Server: Store the User Information

Group chat: Group started by Client

  • Server Provide all users for Client User to select.

Management of connections: Give every User a Threads

起初,我们并没有引入多线程,我们只是在客户端轮流执行信息的收发,结果我们发现,在这种情况下,客户端无法实现并发的收发数据,而是只能一收一发,如果没有收,或者没有发,那么客户端就会阻塞。

在我们引入多线程后这个问题就得到了解决。客户端可以并发的处理收发操作。

同时,我们在服务端引入了mutex来保证传输数据的正确性。当多个用户向同一个用户发送数据时,服务器push 传输的数据进入 特定用户的消息队列 上锁

BackLink