ChatLand is an Internet Relay Chat server written in Java. This was a homework assignment completed as part of the Advanced Java course at Bloomsburg University for Dr. Youmin Lu, as a student, in Fall of 2010.
Criteria for the assignment was to write a thread-safe, stateful multi-user system to utilize sockets. The server utilizes intrinsic locks and guarded blocks (i.e., Object.wait()
and Object.notifyAll()
) to achieve CPU-efficient concurrency. The author personally selected IRC as a theme for this assignment.
This server partially implements RFC 1459. The majority of the protocol is not implemented, but enough is implemented to support very primitive chat use.
The server has been tested with irssi and XChat.
The easiest way to run ChatLand is to build and run it within NetBeans.
- Clone this repository,
- Open the project in NetBeans,
- Run the project!
- The server will listen for IRC client connections on TCP port
7776
. - Please connect at least two users to the server after start-up.
ChatLand is alpha quality software, it was a homework assignment. Some issues are recorded in the repository's issue tracker.
As of now there is no serious intention to deliver an executable for general purpose use.
There are 2 + (userCount * 2)
threads running at any given time.
- The first thread,
Main
, loops forever and is blocked byServerSocket.accept()
. - The second thread,
IRCWorker
, loops forever and is blocked until input from a client (which is a third, fifth, or higher thread) invokesnotifyAll()
, thus indicating aMessage
is available to be processed. - The third (or any odd numbered thereafter) thread,
ClientInput
, receives textual input from a remote IRC client, and is blocked byScanner.nextLine()
.- Again, this thread will
notifyAll()
theIRCWorker
thread after inserting aMessage
into its queue.
- Again, this thread will
- The fourth (or any even numbered thereafter) thread,
ClientOutput
, sends textual output to remote IRC client, and is blocked while waiting for theIRCWorker
thread to insert aMessage
into the output queue.
- Each connected client has its own
IRCHandler
.- The
IRCHandler
may be thought of as the bridge between the two dedicated client threads (ClientInput
,ClientOutput
), and theMessage
processingIRCWorker
thread.
- The
- There is one worker thread (
IRCWorker
) to update the state of the IRC server as it processes theMessage
objects from the client queues.- After significant adjustment, it would be possible to have multiple
IRCWorker
threads to increase throughput.
- After significant adjustment, it would be possible to have multiple
- The server does not utilize any thread pools.
This project is the sole work of the author ultasun. Please see the LICENSE
. Thank you for reading!