Client-Server Networking Between PHP Client and Java Server

Posted by Muhammad Yasir on Stack Overflow See other posts from Stack Overflow or by Muhammad Yasir
Published on 2010-04-21T10:25:01Z Indexed on 2010/04/21 10:33 UTC
Read the original article Hit count: 665

Filed under:
|
|
|
|

Hi there, I have a university project which is already 99% completed. It consists of two parts-website (PHP) and desktop (Java).

People have their accounts on the website and they wish to query different information regarding their accounts. They send an SMS which is received by desktop application which queries database of website (MySQL) and sends the reply accordingly. This part is working superbly. The problem is that some times website wishes to instruct the desktop application to send a specific SMS to a particular number. Apparently there seems no way other than putting all the load to the DB server... This is how I made it work. Website puts SMS jobs in a specific table. Java application polls this table again and again and if it finds a job, it executes it. Even this part is working correctly but unfortunately it is not acceptable by my university to poll the DB like this. :(

The other approach I could think of is to use client-server one. I tried making Java server and its PHP client. So that whenever an SMS is to be sent, the website opens a socket connection to desktop application and sends two strings (cell # and SMS message). Unfortunately I am unable to do this. I was successfully to make a Java server which works fine when connected by a Java client, similarly my PHP client connects correctly to a PHP server, but when I try to cross them, they start hating each other... PHP shows no error but Java gives StreamCorruptedException when it tries to read header of input stream.

Could someone please tell what I can try to make PHP client and Java server work together? Or if the said purpose can be achieved by another means, how?

Regards, Yasir

© Stack Overflow or respective owner

Related posts about php

Related posts about java