Solved

question about chat programs in Java

Posted on 1998-08-27
4
283 Views
Last Modified: 2010-07-27
i have seen chat program code (client/server) to be
implemented across the Internet using Java.But for that we need the
server to be www.mychat.com. What i want to know is that can
we write a similar chat prog in Java and implement it on
a LAN running Win NT? If so, what would the code be like?
0
Comment
Question by:riddhi_barman
  • 2
4 Comments
 

Author Comment

by:riddhi_barman
ID: 1222670
Edited text of question
0
 

Author Comment

by:riddhi_barman
ID: 1222671
Edited text of question
0
 
LVL 8

Expert Comment

by:diakov
ID: 1222672
Hm, interesting number of points for this type of question...

In your case you have to write the communication between the client and the server using sockets. First, I hope your LAN ahs IPs assigned to each machine.
The server listens to a particular socket on the NT machine. The client contacts this socket and announces himself to the server program. Then, you have to define some simple messaging protocol, in order to be able to implement the chat sessions.

The Web chats are something else. They use the HTTP layer to transport their messages and since the connection there is stateless, the chat server CGI program must have a way to distinguish the different chat clients, which the do through cookies in the browser or some other way.

Cheers,
  Nik
0
 

Accepted Solution

by:
vali earned 0 total points
ID: 1222673
Hi Riddhi,
I begin my answer by telling you that I have just finished a java client/server application specially designed for CHAT.
First of all you have to understand is that you need a server and a client. The server MUST be for sure a "java application", the client doesn't need to be a "java application" but also an applet.
The server will run all the time waiting for a client to connect to it. When a client is trying to connect the server opens a link to it beginning the communication.
Using a server-application and a client-applet, your client and server MUST be physically on the same machine.
Using a server-application and a client-application, your client may be located on other machine but where the server is.
As java facilities for communicating in a network (e.g. LAN) are only through TCP/IP or UDP protocols, your network must implement them too. So you choose which protocol you want to use further on for your client/server communication (I advise you to choose TCP/IP).
After you chosen the protocol you have to choose a port number the server is waiting on (e.g. 5454). The port number must be between 2000 and 65535 (because some systems use 1-2000).
So finally the server is waiting for a client to connect at a certain port number. The client must specify the server IP address and the port number it listens to. Once a client is connecting the server opens a socket to the client.
In chat communication when a certain client sends a message the server receives it and sends it to all the other clients connected to it.

Good luck!!!
Vali,  


0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question