1

Can I use PHP modules, such as the one found in PEAR's Net_Socket library, to have socket communications to a client-side in-browser Java Applet (presumably using java.net.Socket)? If so, how? Perhaps an example somewhere?

The reason here being a two parter: 1) With the popularity of Java apps on mobiles devices I can make a Java program once, and it can be easily ported to a mobile app from Java applet when the time comes. and 2) cheap shared web hosting doesn't typically support custom Java servers (not even Node.js). So, I'm looking for a way to make a server for my Java apps with socket based communication. With this in mind, there is then a less specific question (optional):

Is there any way, or a preferred way, (say using CGI/Perl, PHP/Python) to setup socket communications between the free services found on a cheap web host and my client-side Java apps?

(for instance, say I'm trying to make a simple chat room)

NOTE: I did find this question: How to implement communication between Java client application (Android) and PHP server application? But it doesn't apparently involve sockets. So a chat room would require the client to pole.

7
  • look at this post stackoverflow.com/questions/6906660/…. Basically it suggest to use JSON over http because of PHP's capabilities. Also,just a small note for japplets, take a look at what they can and cannot do. If your user doesnt accept signed java-applets, you cant use sockets : docs.oracle.com/javase/tutorial/deployment/applet/security.html Commented Dec 23, 2012 at 14:05
  • @user1724140 - Interesting, but as far as I can tell, using JSON would still require the client to pole, instead of the server pushing. Also, wouldn't it still require the headers to be sent with each message? Possibly drastically increasing used bandwidth. Commented Dec 23, 2012 at 14:21
  • The major issue that your referenced question brings up; is whether or not you really need real-time communications. As chubbsondubs said is his comment to his own answer. I suppose as long as I can get the server to push data without client poling, then it would be real-time enough. Commented Dec 23, 2012 at 14:28
  • And as far as your comment about the user having to accept signed Java applets for it to work at all. Is there a solution using WebSockets that would prevent this? Commented Dec 23, 2012 at 14:31
  • 2
    Well, it appears that as long as the Java connects to the host it came from, then using sockets should not require user approval for unsigned applets. Commented Dec 23, 2012 at 14:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.