kAmol
kAmol

Reputation: 1389

How to bind java applet to socket?

I've created paint like applet, and wants to embed it in webpage.(I know its not a issue).
The problem is, the client editing paint applet should get replicated(means another client should be able to see the changes) to another client, something like chatting, how to do it?
do I need to use java socket to bind the applet, will that be feasible? thanx in advance..

Upvotes: 0

Views: 155

Answers (2)

user207421
user207421

Reputation: 310988

There is no such thing as an 'bind[ing] an applet to a socket', or anything else binding to one either, but an applet certainly can create a socket. An unsigned applet can only connect to the host it was loaded from: a signed applet, to anywhere. It can also create a listening socket.

However clients live behind firewalls, so your entire approach is no good anyway. All the applets should communicate with a server at the host they were loaded from.

Upvotes: 1

SJuan76
SJuan76

Reputation: 24895

An applet cannot bind to a socket(*), and for good reasons (imagine the security nightmare that would be). And even if it could, there would be still the issues of configuring firewalls, NATs and all those funny things.

Make both applets connect to a common servlet (from the host were the applet was downloaded from) and interchange information through the server (the applet is the one starting the connection). Check UrlConnection and HttpUrlConnection.

*: Maybe an applet signed by a valid CA could (I am not sure) but even then getting the certificate is another issue, and the configuration problems would remain.

Upvotes: 3

Related Questions