Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Limit of bytes that can be sent to server?

 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I have some j2me code that I got from a tutorial that sends a picture that is captured from the screen of the phone and is sent to my asp.net webpage.

The picture length is like 78,000 bytes and then I encode it base64 and I am not sure how long it is after this.

I then use the outputStream to send it.

When it hits my asp.net webpage I use

Stream stream = Request.InputStream;

I get a length of 0.

I played around and found that the max bytes that seem to work is 1512 and when it his my C# line above it has a length of 2016. Is this how it should be?

Like the tutorial I was going through used java servlets to do it and this is what they did

InputStream in = request.getInputStream();

So it is almost the same as my c# code.

but they don't say anything about any limits or anything on how much can be sent.

 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HTTP requests are blocking streams. There is nothing at the server side until you read it. So just read the stream up to the last bit.

If you want to know the content length beforehand, you can usually find it in the request header. But you shouldn't rely on it only, because the value can be spoofed or 'forgotten' by the software used at the client side.
 
Michael Hubele
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bauke Scholtz wrote:HTTP requests are blocking streams. There is nothing at the server side until you read it. So just read the stream up to the last bit.

If you want to know the content length beforehand, you can usually find it in the request header. But you shouldn't rely on it only, because the value can be spoofed or 'forgotten' by the software used at the client side.



Sorry I am not following.

I tried to read the stream if I am understanding you correctly.

Stream stream = Request.InputStream;
StreamReader streamReader = new StreamReader(stream);

string test = streamReader.ReadToEnd();
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try a forum devoted to C#.

At least I can tell you that HTTP requests are blocking IO. In Java you should basically read every byte of the inputstream in a loop until its value is -1.
 
Michael Hubele
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bauke Scholtz wrote:Try a forum devoted to C#.

At least I can tell you that HTTP requests are blocking IO. In Java you should basically read every byte of the inputstream in a loop until its value is -1.



hmm I will try a C# form but they probably go and tell me to go to a j2me forum.
 
Saloon Keeper
Posts: 24334
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1512 bytes sounds like a limit for an HTTP GET. I think you're trying to do this the hard way.

Set up your C# server to do file uploads. Then write the J2ME code as a file upload client using HTTP POST. POST, unlike GET is designed for very large amounts of data to be sent to the server.
 
Michael Hubele
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:1512 bytes sounds like a limit for an HTTP GET. I think you're trying to do this the hard way.

Set up your C# server to do file uploads. Then write the J2ME code as a file upload client using HTTP POST. POST, unlike GET is designed for very large amounts of data to be sent to the server.



Hmm I am not sure what you mean make C# server to do file uploads. IN my j2me code I am using a Post I did the setting as a post.

c.setRequestMethod(HttpConnection.POST);

I thought there might be a limit on what .net allows but changed the limit from 4mb(what should have been tons) to 100mbs. I also tried sending the string that makes up the jpg through a diff .net website and it works no problem.

So i don't know what is up. The .net that send the jpg used a dataStream since I could not find really how to use the .net outputStream where the j2me midlet uses the output stream but the code that grabs the image from either one is the exactly the same.

 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic