Back to Blog

Linux Chat Room Program

#Linux#Multithreading#Server#Programming#Java#Chat

======================================= Objective =======================================

Advanced Programming in Linux Environment (Part 1)

Implement a multi-user chat room program using TCP protocol with threading. (2 weeks)

The following features must be implemented:

  1. A server-side program capable of handling multiple client programs.

  2. Support for one-to-one and one-to-many chat.

  3. File transfer functionality.

  4. File integrity verification.

  5. Demonstrate solutions for resolving shared resource conflicts in inter-thread communication.

===================================================================================

1. Introduction

  1. Can JAVA GUI applications run on Linux?

Java compiles into bytecode, which is platform-independent and executed by the JVM. Therefore, .class files can run anywhere a JVM is available.

  1. Can Java programs compiled on Windows run on Linux?

Can a program compiled with JDK for Windows run in a Linux environment using JDK for Linux? Also, can JBoss, which runs well on Windows, operate on Linux?

Answer: Java bytecode is platform-independent and interpreted by the JVM. Hence, .class files can run on any platform with a compatible JVM.

  1. Can Java be installed on Linux?

Yes. Installation instructions can be found at: http://blog.csdn.net/yeyuangen/article/details/6728004

  1. Can a chat room program developed on Linux run on Windows?

Answer: Yes, provided the program is written in a platform-independent manner (e.g., using Java with proper cross-platform considerations).

  1. What is a server-side application? What are the differences between server-side and client-side programs?

Answer: The server must use multithreading because it handles multiple concurrent tasks.

  1. Ericsson server, debug? What needs to be done?

Answer: Learn more from Hanbin, and attend the IBM training on September 23.

  1. Login interface related

Answer: Username and password (retrieval and matching via a small database)

  1. Purpose of the server-side

Answer: Forwarding data between clients

  1. How do clients communicate with each other? For example, how do they send files?

Answer: All communication and decisions must go through the server.

  1. Other features: Screen shake, add friends

  2. How to test on a single machine? How to test over a network (using two computers)?

2. Multithreaded Communication and Mutual Exclusion

============

Multithreading

============

  1. Does this need to run on ARM?

Answer: Running on a PC is sufficient.

  1. Can this be written in Java, or must it be in C?

Answer: Use C. The goal is to gain hands-on experience with thread control, conflict resolution, and inter-thread communication.

  1. How should multithreading be implemented effectively? How to better understand multithreading? How to gradually grasp the theoretical implementation of multithreading from practical applications? (Clear mental model)

Answer:

  1. How to resolve communication conflicts? How to ensure orderly access?

3. Network Programming

===========

Socket

===========

  1. Socket programming

  2. TCP

  3. Network

  4. What is the essence of a socket?

Answer: It is I/O—specifically, file I/O.

  1. How to use sockets proficiently?

  2. What are the key terms and concepts in socket programming? (Beginner level)

  3. How to implement socket programming? Run through example code to gain intuitive understanding.

  4. What is the first principle of socket programming?

4. Running Sample Programs

  1. How to run sample programs?

  2. What can be learned from running sample programs?

Answer: Gain an intuitive understanding of threads and build motivation for learning multithreading.

5. MIT Practice

  1. It seems that changing strategy from Java or Qt implementation is necessary: Just work independently in your dorm. Building something like QQ could actually be quite inspiring.