SunQuest
           Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old June 27th, 2002, 12:10 PM
colpaarm's Avatar
colpaarm colpaarm is offline
300lb Bench!
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2001
Location: New York
Posts: 2,191 colpaarm User rank is Corporal (100 - 500 Reputation Level)colpaarm User rank is Corporal (100 - 500 Reputation Level)colpaarm User rank is Corporal (100 - 500 Reputation Level)colpaarm User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 5 h 8 m 19 sec
Reputation Power: 11
Problems identify and sending eof

We've created a java servlet/java application to handle file uploads. The servlet gets a multi-part form request that has name value pairs and a file. The servlet then parses through the header, separates the name value pairs into an object and streams the file over to the java application through a socket. Here's the problem.

The java application receives the file, does some processing, then sends a response back to the java servlet. Or at least, that's what we want to happen. The problem is the fact that the java application never quite knows when the end of file is reached. So it's getting binary information from the servlet (a buffer at a time). Once it gets everything, it's still waiting for more because it doesn't know that it got everything. On the other end, the servlet has sent everything and is waiting for the response from the java application so that it can display the results of the file operation to the user. Both sides are waiting, nothing is happening and the user finally receives a read error (because the servlet never got it's response to show the user).

We thought about sending very specific binary delimeters. For example, take the string "^*^*", convert that to binary, then send that. But there's no real delimeter that you can use and ensure won't be part of the upload. Furthermore, this method slows things down to a crawl. Why? Because the java app has to check each time it receives a buffer to see if it contains the delimeter. We thought we could solve that problem by checking for the delimeter only when the buffer size was less than what was specified. In other words, we tell the servlet to stream the file to the app in, let's say, 10k chunks. Any time the app gets less than a 10k chunk, that must be the last transmission, right? Just ensure that by checking for the delimeter and you're fine? Well, java doesn't necessarily have to send the chunk size that you tell it to send it. The number that you specify just simply tells java what the maximum you want to send at one is. There's actually other implications but I won't get into them. The other solution is to check with every chunk. That takes about 100 years and is not viable.

I've come a long way to ask this question, so here it is. What is the eof delimeter? If I knew what that was, I could send it and the java app would know to stop looking for more bytes. Realize that closing the stream used to send info over the socket is not an option because we have to wait for a response from the java app. Thanks for your help.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Problems identify and sending eof


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway