?
Solved

question about chat programs in Java

Posted on 1998-08-27
4
Medium Priority
?
300 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month13 days, 2 hours left to enroll

777 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