Question about URLConnection

Reply

Join Date: Nov 2004
Posts: 189
Reputation: George2 is an unknown quantity at this point 
Solved Threads: 0
George2 George2 is offline Offline
Junior Poster

Question about URLConnection

 
0
  #1
Mar 9th, 2005
Hello everyone,


I am using HTTP protocol to transfer large amount of data across two machines. And I have found out that some packages will be lost when using the following source codes. I am wondering whether there are anything wrong or potential issues in them.

Data request

  1. URLConnection conn = url.openConnection();
  2. conn.connect();
  3. InputStream is = conn.getInputStream();
  4. while (true)
  5. {
  6. // read a buffer from is
  7.  
  8. // if no more data, escape from while loop
  9.  
  10. // process the data contained in the buffer
  11. }

Data response

  1. protected void doGet(HttpServletRequest req, HttpServletResponse
  2.  
  3. res) throws ServletException, IOException {
  4.  
  5. OutputStream os = res.getOutputStream();
  6. while (true)
  7. {
  8. // read a buffer from a large file
  9.  
  10. // modify buffer according to application logics
  11.  
  12. // if no more data, escape from while loop
  13.  
  14. // write modified buffer to os
  15. }
  16.  
  17. }

I am wondering whether the package losing is caused by the reason that, data response is too fast than data receiving so data receiving application will miss some chances to read packages.

I am also wondering what is the effective approach of transfering data across two machines using HTTP protocol without losing any packages. Are there any online samples?


Thanks in advance,
George
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: Question about URLConnection

 
0
  #2
Mar 9th, 2005
I could be wrong about this, but I would think no matter how you do it, it would be possible to loose some packets due to the quality of the connection, and so forth. Again, I could be wrong, so maybe somone that knows a little more than me can help you.
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 189
Reputation: George2 is an unknown quantity at this point 
Solved Threads: 0
George2 George2 is offline Offline
Junior Poster

Re: Question about URLConnection

 
0
  #3
Mar 9th, 2005
Thanks server_crash,


Originally Posted by server_crash
I could be wrong about this, but I would think no matter how you do it, it would be possible to loose some packets due to the quality of the connection, and so forth. Again, I could be wrong, so maybe somone that knows a little more than me can help you.
Your idea is very helpful. Do you know any online resources dealing with similar topics?


regards,
George
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: Question about URLConnection

 
0
  #4
Mar 10th, 2005
Sorry, I don't know very much about network programming. Hopefully, someone that knows something about it will come along and help you. sorry!
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 189
Reputation: George2 is an unknown quantity at this point 
Solved Threads: 0
George2 George2 is offline Offline
Junior Poster

Re: Question about URLConnection

 
0
  #5
Mar 10th, 2005
Never mind server_crash, thanks all the same.


Originally Posted by server_crash
Sorry, I don't know very much about network programming. Hopefully, someone that knows something about it will come along and help you. sorry!

regards,
George
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC