• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

socket response

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am writing a file to a socket and then trying to read a response.

There is a jsp which receives the call and processes the data. In my jsp I can see that the request is handled correctly and the response line is reached in less than 1 second.

However on the client (Applet) I wait in a loop for almost a minute and then receive a socket closed message.

I never see my output from the jsp.
out.println("bytes/elapsed: " + String.valueOf(lgBytesTransferred) + " : " + (System.currentTimeMillis() - lgstart));


I only receive:
communicator. read response: HTTP/1.1 200 OK
communicator. read response: Date: Tue, 29 Jul 2008 19:59:58 GMT
communicator. read response: Server: Apache/2.0.58 (Unix) mod_ssl/2.0.58 OpenSSL/0.9.8a PHP/5.1.4
communicator. read response: Content-Length: 0
communicator. read response: Connection: close
communicator. read response: Content-Type: text/plain; charset=ISO-8859-1
communicator. read response:

=============================================
// write the file bytes to the socket
int bytesRead=-1;
while ( ((bytesRead = fis.read(buffer)) != -1) )
write(buffer, 0, bytesRead);

// wait for a response
BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
while( (strInputLine = br.readLine()) != null )
System.out.println("response: " + strInputLine.trim());
 
Robert Kennedy
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Resolved:

socket.shutdownOutput();
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic