UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » Java
  • » chat application with java

#1 2008-11-21 08:48 PM

wa7ch3000
Member
Registered: 2008-11-21
Posts: 3

Re: chat application with java

I've just know about programming on linux, so i want to write a chat program by java, can everybody help me about source code???(just text,no voice,may be chat on LAN). THANKS!!!

:???:

Offline

#2 2008-11-21 10:03 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,829
Website

Re: chat application with java

I don't really know much java myself, but pretty much anyone here that does is likely
to first ask: Do you have any specific questions/problems?  Your question now is
extremely vague and unclear...  Are you just asking someone to supply you with code
for an existing chat app?  (If so, how does that qualify as YOU writing it??)  If that's
all you want, I suggest going to FreshMeat or SourceForge or some similar place,
and just searching for "java chat" or similar...

Offline

#3 2008-11-21 11:35 PM

wa7ch3000
Member
Registered: 2008-11-21
Posts: 3

Re: chat application with java

RobSeace;25517 wrote:

I don't really know much java myself, but pretty much anyone here that does is likely
to first ask: Do you have any specific questions/problems?  Your question now is
extremely vague and unclear...  Are you just asking someone to supply you with code
for an existing chat app?  (If so, how does that qualify as YOU writing it??)  If that's
all you want, I suggest going to FreshMeat or SourceForge or some similar place,
and just searching for "java chat" or similar...

THANK YOU  :rolleyes:

Offline

#4 2008-11-22 02:08 AM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,230

Re: chat application with java

For some mysterious reason a chat program is something that a lot of people seem
to want to make when they learn programming, as well as being a classic
homework assignment.

Offline

#5 2008-11-22 06:37 PM

jfriesne
Administrator
From: California
Registered: 2005-07-06
Posts: 348
Website

Re: chat application with java

It's not so mysterious... chat programs are fun, and not too difficult to write.

Offline

#6 2008-11-22 10:53 PM

wa7ch3000
Member
Registered: 2008-11-21
Posts: 3

Re: chat application with java

hello
while you said that they are easy to program ;could you PLZ help me to start my application.
all documentation, or documentation or advice are welcome

Offline

#7 2008-11-23 04:05 AM

jfriesne
Administrator
From: California
Registered: 2005-07-06
Posts: 348
Website

Re: chat application with java

wa7ch3000;25532 wrote:

hello while you said that they are easy to program ;could you PLZ help me to start my application.  all documentation, or documentation or advice are welcome

The very simplest chat program I can imagine would be one that worked just over a LAN, using UDP broadcast packets.  Each client would create a UDP socket, bind it to a well known port (pick any port number over 10000 or so to be safe), then select() on both that socket and on STDIN_FILENO.  Whenever FD_ISSET(&readSet, STDIN_FILENO) is true, fgets() the string the local user typed in to stdin, and send() that string to your UDP broadcast socket, so that the string gets broadcast to all the other clients.  Whenever FD_ISSET(&readSet, myUdpBroadcastSocket) is true, recv() the data from the UDP socket and puts() the data, so that the received data can be read by the user.  That's it :^)

Offline

#8 2008-11-24 03:08 AM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,230

Re: chat application with java

Considering he's using Java it's probably easier to make a multithreaded client.
E.g. one thread for the GUI, and one (or more) for the network stuff.

Offline

#9 2008-11-24 04:50 AM

jfriesne
Administrator
From: California
Registered: 2005-07-06
Posts: 348
Website

Re: chat application with java

i3839;25551 wrote:

Considering he's using Java it's probably easier to make a multithreaded client.  E.g. one thread for the GUI, and one (or more) for the network stuff.

Good point... I had forgot he was wanting Java.  Although as I understand it the Java nio classes do have equivalents to select() and friends... I don't know if multiple threads make things harder or easier for this case, but in general they do make it harder to verify that the program is 100% correct.

Offline

  • Index
  • » Java
  • » chat application with java

Board footer

Powered by FluxBB