GitXplorerGitXplorer
a

cliserchat

public
0 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
471631b782b89fedb73f0e650d0a24fd5f3291d3

Update Demo

aabchk1234 committed 11 years ago
Unverified
791117706be3280bc3f68bf64a21d0ea1f9565fa

Add support for quitting the application using /quit

aabchk1234 committed 11 years ago
Unverified
58617bc418d1d0cbbb7e47fa4be7624cae56165c

Update Client to have default port 1025 even when connecting to remote server

aabchk1234 committed 11 years ago
Unverified
f53911e09ca30b8ffdea56d686af6c6db5bb53b0

Update readme

aabchk1234 committed 11 years ago
Unverified
f8c9c9416040d1214da4c82e8a5a5cad7d493669

Add License

aabchk1234 committed 11 years ago
Unverified
0afac85b645c54d85952557e89d8160050b03137

Update

aabchk1234 committed 11 years ago

README

The README file for this repository.

This is a Client-Server Chat Application, written in java, using sockets. Using this one can connect 2 people/computers/terminals.

Requirements- java (jre / java runtime environment)

Usage-

The Server program is named as MyServer.class and the Client program is named as MyClient.class

The Server needs to be started first. It can be started by typing MyServer in the terminal, inside the folder where the MyServer.class file is present:

$ java MyServer

Then the Client can be started similar to the server, like:

$ java MyClient

By defualt, when no arguments are specified, both the client and server are assumed to be on the same system/host, and the port 1025 is used for communication.

Different ports for the server can be used as:

$ java MyServer 2055

Then to connect the client to the server:

$ java MyClient 2055

This assumes that the server is on the same system/host as the client; if the server is located elsewhere, one can use the form:

$ java MyClient 192.168.1.4

Here 192.168.1.4 is the IP address of the server.

If you get a "Connection refused" exception, then perhaps you have given the wrong IP or port address.

When connecting from different machines, the ports for the communication should be available; otherwise you could get a "Connection timed out" exeception.

Code-

The code is included along with the class files, as MyServer.java and MyClass.java, and is licensed under the GNU GPL.

If the class files are not running on your system, or you want to modify the code, one can use-

$ javac MyServer.java

and

$ javac MyClient.java

to compile the code to class files (requires jdk / java development kit).

Note-

This application is not multithreaded, so at a time only a single client can chat with the server.

If two people want to communicate using this application, one can run the server, and the other can run the client, giving the IP of the server.

If the 2nd person wants to initiate the chat, then he can start the server, and the 1st person can run the client.

Demo-

a) Starting the server-

$ java MyServer

Client-Server Chat Application

Press Ctrl^C or Alt+F4 to quit this application.

Server- Using port: 1025 Waiting for connection from Client..

b) Starting the client on another terminal and typing a message-

$ java MyClient

Client-Server Chat Application

Press Ctrl^C or Alt+F4 to quit this application.

Client- Using port: 58541 Successfully connected to Server. IP: /127.0.0.1 Port: 1025 Name: localhost

Enter message (Type /y to terminate the message) : Hello /y

Waiting for response...

c) The server gets the clients message and responds-

Connection received from client. IP: /127.0.0.1 Port: 59048 Name: localhost

Waiting for response...

CLIENT-> Hello

Enter message (Type /y to terminate the message) : Hi /y

Waiting for response...

d) The client receives the message-

SERVER-> Hi

Enter message (Type /y to terminate the message) : How are you? /y

Waiting for response...

e) And so on..

On pressing Ctrl^C, the application quits.