• Post Reply Bookmark Topic Watch Topic
  • New Topic

socket recovery  RSS feed

 
Robert Kennedy
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

If I have a socket to which I am writing (http file upload) and an error occurs, can I recreate the socket without closing the underlying BufferedOutputStream, and if the new socket is created successfully, can I continue to write data to the socket?

will this be affected by a new socket or is socket simply a pointer:
bos = new BufferedOutputStream (socket.getOutputStream());

and can I just continue writing to the new socket:
bos.write (buf,offset,size);

Thanks
 
Joe Ess
Bartender
Posts: 9426
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. Once you lose the socket, you lose the output stream. This strategy would not work anyway because you don't know if all the data you wrote to the stream reached the server or was lost in transit when the socket went down.
 
Robert Kennedy
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your response. I will try to accomplish what is required using a small thread pool.
 
T.A. Nguyen
Ranch Hand
Posts: 36
Eclipse IDE Java ME Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to visit and consider joining the "Download Manager" open source on sourceforge.net

http://sourceforge.net/projects/dwjava/

have fun,
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!