Hello, I have a problem here. I have 2 machines. 1 is a webserver and
the other is the client machine. The client machine calls the webserver
to execute a particular application. Now the problem is my client
machine (using Java's HTTP.... classes) keeps on waiting until the
process in the web server finish executing. The code below calls the
webserver:
public void caller()
{
String host = "www.google.com";
String content = "hello...";
try
{
URL url = new URL(host);
URLConnection uc = url.openConnection ();
if (!(uc instanceof HttpURLConnection))
{
System.err.println ("Wrong connection type");
return;
}
uc.setDoOutput (true);
uc.setUseCaches (true);
HttpURLConnection hc = (HttpURLConnection) uc;
hc.setRequestMethod ("POST");
OutputStream os = uc.getOutputStream ();
DataOutputStream dos = new DataOutputStream (os);
dos.writeBytes (content);
dos.flush ();
dos.close ();
uc.connect();
// -- HERE (Get the reply of the webserver)
InputStream is = uc.getInputStream ();
int ch;
while ((ch = is.read ()) != -1)
System.out.print ((char) ch);
is.close ();
// -- HERE (End)
}
catch (Exception e)
{
System.out.println(ipAddr+" "+e.getMessage());
}
}
Once, I erased the portion bet HERE but the apps in the webserver did
not work. Please do reply. thanks.
Martin Gregorie - 22 Jul 2006 11:37 GMT
> Hello, I have a problem here. I have 2 machines. 1 is a webserver and
> the other is the client machine. The client machine calls the webserver
[quoted text clipped - 51 lines]
> Once, I erased the portion bet HERE but the apps in the webserver did
> not work. Please do reply. thanks.
Try connecting before sending the message to the server.

Signature
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |