Solved

question about chat programs in Java

Posted on 1998-08-27
4
277 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java Timer (static) 9 44
nextBoolean(double p) for Random class 3 40
javap not working 8 46
hibernate jars 4 32
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.

810 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