Solved

question about chat programs in Java

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now