applet to applet communication over lan

J

Jade

is it possible to make 2 applets communicate from 2 seperate pc's over
a lan without a server? they are loaded from the same html file on a
network drive for both pc's. i am a java newbie, so please go easy on
me ;) an example would be nice if possible
 
R

Roedy Green

is it possible to make 2 applets communicate from 2 seperate pc's over
a lan without a server? they are loaded from the same html file on a
network drive for both pc's. i am a java newbie, so please go easy on
me ;) an example would be nice if possible

Yes, but they must be signed. One has to open a server socket, the
other a client socket. Then they can pump data back and forth.
Alternatively they could send UDP datagrams at each other.
see http://mindprod.com/fileio.html for how to do the client side
socket. See Marty Hall's book for how to do the server side. See
http://mindprod.com/jgloss/cgi.html


One problem is finding each other. The client needs to know the DNS
name or the IP of the server. You might use DYNDNS for this. See
http://mindprod.com/jgloss/dyndns.html
 
J

J Skaggs

Yes, but they must be signed. One has to open a server socket, the
other a client socket. Then they can pump data back and forth.

Is there any resources on the web that describe how to do this?
 
R

Roedy Green

One problem is finding each other. The client needs to know the DNS
name or the IP of the server. You might use DYNDNS for this. See
http://mindprod.com/jgloss/dyndns.html


Let's say this is a chat application. What you could do is have a
simple chat server. It does not relay messages. All it does it tell
everyone participating in a given chatroom everyone else's IP number.
So every time somebody joins, everyone's applet in that chatroom gets
a message. From then on speakers send multiple copies of the message
to all other chatroom participants, offloading the server. They could
use UDP with everyone listening on the same port. You may lose a
message every now and then, but that would not be critical for chat.
The ability to run a huge chatroom on a dinky server makes up for it.
All it has to do is track which participants are in which chatrooms.

You can prune the traffic back even further by having participants
automatically notify the others when they enter or leave. You could
have a "gc" sweep every once in a while to notify everyone of the
participants to help correct for lost messages.


The disadvantage of this scheme is less anonymity. A hacker could
harvest ip addresses of participants.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top