Skip to content
Advertisement

Java Socket Server with PHP client

the question is totally rewritten since I have understood that previously it was really unclear. I have created a Java Socket server with threads to accept multiple connection in order to handle php tcp requests. The java server just for the testing purposes it reverse the string supplied from php. Java server is hosted on a ubuntu server and the php is located on another machine. The java server shows that php client is connected, but the php is not loading and the string is not sent. From the codes given below what could be the mistake?

UPDATE the problem is the received string from the Java server. I have checked with debugger and the BufferedReader is full of ‘u0000’ and server stops responding. The rest code and communication is working perfect. How I can avoid those null characters or decode the string correct?

ReverseServer

JavaScript

ServerThread

JavaScript

PHP client

JavaScript

Advertisement

Answer

I am trying to read a line, but on the string given on the php client didn’t had the carriage return symbol “r”. Once I have put this on the string it works as expected.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement