如何在Java Applet和PHP服务器之间进行套接字通信?

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.