• Post Reply Bookmark Topic Watch Topic
  • New Topic

Finding Clients on a Network

 
John Bartlett
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I am currently working on a TCP Chat program which allows people to talk to other people on their local network (for now) and was wondering how to do the following:

When the user loads up the program I want it to locate all users on the local network running the same software and connect to them.

The way I was hoping to do this is:

1) User loads the program
2) It sends a message to all other computers saying "logging on"
3) once a user receives that message they add the user to a directory array and send a message back saying "logged on"
4) Then the original sender will then add that person to their directory array.

This way the person who logged on will be able to build up a list of all people already logged on.

But I am at a bit of a loss on how to do this. I have found multicasting using DatagramPackets and MulticastSockets but am not sure if this is the best method?

I would like to just use PrintStreams and BufferedReaders if possible?

Please if anyone has any ideas on how to do this I would be really grateful for any feedback?

Thank you,

John
[ May 06, 2006: Message edited by: John Bartlett ]
 
amod gole
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi John Bartlett ,

i will give you one clue, use threading for this
and one more think from server side dont think that you are client

multitple client connecting to you and you are directing to all of them

bye....

 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A "hub and spoke" kind of thing is probably common here. Make a chat server on one machine. As each client logs on or off they tell the server and the server keeps track of who is logged on.

You could send messages through the server which forwards them to the recipient, or you could connect from one user to another. Either way, each client could open a ServerSocket to accept inbound messages. That's an interesting reversal of client and server roles that lets you send all messages with a short lived connection: connect, send, disconnect.

Have you done the Sun Sockets Tutorial? It's a great start.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!