| | |
Question about URLConnection
![]() |
•
•
Join Date: Nov 2004
Posts: 189
Reputation:
Solved Threads: 0
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
Data response
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
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
Java Syntax (Toggle Plain Text)
URLConnection conn = url.openConnection(); conn.connect(); InputStream is = conn.getInputStream(); while (true) { // read a buffer from is // if no more data, escape from while loop // process the data contained in the buffer }
Data response
Java Syntax (Toggle Plain Text)
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { OutputStream os = res.getOutputStream(); while (true) { // read a buffer from a large file // modify buffer according to application logics // if no more data, escape from while loop // write modified buffer to os } }
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
•
•
Join Date: Nov 2004
Posts: 189
Reputation:
Solved Threads: 0
Thanks server_crash,
Your idea is very helpful. Do you know any online resources dealing with similar topics?
regards,
George
•
•
•
•
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.
regards,
George
![]() |
Similar Threads
- Question about URLConnection (Java)
Other Threads in the Java Forum
- Previous Thread: number formatting using recursion
- Next Thread: cannot link a form to a nonform application in microsoft j++
| Thread Tools | Search this Thread |
-xlint add android api applet application array arrays automation bank bi binary blackberry bluetooth chat class client code compile compiler component converter database digit eclipse equation error event fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui health html hyper ide idea image infinite input int integer j2me java javame javaprojects jetbrains jni jpanel jtable julia learningresources linux list login loop main map method methods mobile myregfun netbeans newbie nonstatic notdisplaying page pearl print problem program programming project qt recursion scanner screen scrollbar server set size sms sort spamblocker sql sqlserver string superclass swing system thread threads tree variablebinding windows xor






