GitXplorerGitXplorer
a

cliserchat

public
0 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
31c701b6c9ec6a85c0b1db1d0d4161186b586f2d

Formatting

aabchk1234 committed 11 years ago
Unverified
8fed4a4b01a58a4083a57e609e96f6b9c7d1d858

Remove extra parens

aabchk1234 committed 11 years ago
Unverified
45d12da8bd35e5b2ac5bf4a0e03513c6bbde1205

Make code more readable

aabchk1234 committed 11 years ago
Unverified
75264dc4428c9a51e836f42a1017407ef9c86feb

Make code more readable

aabchk1234 committed 11 years ago
Unverified
4ffa37d57ce1ed5c57707a46de3a72684e649a2c

Fix errors

aabchk1234 committed 11 years ago
Unverified
0c261737d9fab35a0ad90cc27af98a5b6f314e67

Improve error handling when the client or server quits

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.