|
-
Connecting to java chat server from php
Hi,
I had written a java server program which will be requested from a php
script .
Actually ,It 's being used as a database server for my web-based chat .
Means ..,it stores the information like chat messages ,online
users..and so on
the information will be sent and retrieved from different php scripts.
I am opening a socket connection from php to communicate with java
server and sending some data like
$in = "PUT\r\n$userID\r\n$toID\r\n$msg\r\n$time\r\n";
socket_write($socket, $in, strlen($in));
My java server will create a thread for each connection and start
running it.
In thread ,I am receiving the data coming from socket as .....
try
{
BufferedReader br = new BufferedReader( new InputStreamReader(
sk.getInputStream() ));
String action = br.readLine();
if (action == null ) {System.out.println("some null..
returning"); }
if(action.equals("PUT"))
{
/*Some Code*/
}
}
catch(Exception e)
{
System.out.println("error1234:"); e.printStackTrace();
}
It's working almost fine and there is no problem with my logic and
all..
But for some requests from php ,the String 'action' is being null
and no code will be executed in thread .The string 'action' should be a
valid String so that one action in java server can be performed..
But some times as the String being null ,no action will be performed
..It will be a big problem when the action is to PUT or GET the
messages .
I am unable to find what exactly the problem is........
Is it the problem with php socket_write() or java br.readLine() function?
Any help to find what the problem is ..(and also solution ) will be
greately appreciated...
-Prasad
Similar Threads
-
By snowstorm in forum Java
Replies: 3
Last Post: 05-04-2005, 01:01 PM
-
Replies: 3
Last Post: 06-28-2002, 07:36 AM
-
By Glen Kunene in forum Talk to the Editors
Replies: 17
Last Post: 03-23-2002, 12:43 AM
-
By Ellen D Newman in forum java.announcements
Replies: 0
Last Post: 07-11-2001, 12:01 AM
-
By Pat Meaney in forum Java
Replies: 0
Last Post: 03-13-2001, 01:54 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks