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

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

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

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.

Thanks 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

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

Never mind server_crash, thanks all the same.

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