Solved

question about chat programs in Java

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

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
Java: anonymous class 4 54
ejb message driven bean mdb creation steps 2 54
DTD and JAVA versions 1 55
Java regex 5 21
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

732 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