Results 1 to 4 of 4
Thread: Trouble with Buffer Sizing
- 02-04-2008, 08:31 PM #1
Member
- Join Date
- Feb 2008
- Posts
- 3
- Rep Power
- 0
Trouble with Buffer Sizing
I'm extremely new to Java. I took the Fundamentals of the Java Programming Language Course a week ago at Sun's training center, and am now trying to apply some of it in preparation for the Cert exam.
One of the programs I'm trying to write is supposed to read a lot of information over IP, acting as a server. I've managed to create my socket, and create a BufferedReader that can read the data, however, the BufferedReader is filling up at 512 bytes of Data, and I can't figure out how to change it. According to what I've read, when I create the instance, I just need to specify a size, but that doesn't appear to be working. Any ideas?
This is the code I have. You'll see I tried to create it to be size 1024, but it still stops at 512. It doesn't seem to matter what size I put in. I've tried smaller sizes and bigger sizes, but it always fills up at 512 no matter what.
I also tried changing the size of the InputStreamReader, thinking that if the inputstreamreader were too small, the bufferedreader's size wouldn't matter, but I get a compile error that says there's no constructor for InputStreamReader that involves an integer.Java Code:private static Socket s1; private BufferedReader input; public AMXClient() { try { s1=new Socket("10.198.9.1",1320); input=new BufferedReader(new InputStreamReader(s1.getInputStream()),1024); } catch(ConnectException connExc) { System.out.println("Could not connect."); } }
Thanks a bunch!Last edited by Jeff; 02-04-2008 at 08:40 PM.
- 02-07-2008, 12:40 PM #2
Member
- Join Date
- Feb 2008
- Posts
- 3
- Rep Power
- 0
Anybody? I didn't think this was a particularly difficult issue . . . . Is there something more to this than I was aware that makes it more than a quick forum post to solve?
J
- 02-07-2008, 01:32 PM #3
Source
Welcome, Jeff, to the forums!
Your application looks like a client application. So you are reading some data from the server. The buffered reader uses a buffer with size according to your specification. It's basically how big the pages are in a book. If a book contains 512 words and your pages can contain 1024 words then your book will be only one page long. This will affect caching. If a page can only contain 128 words, then the book will have 4 pages, but it will still contain 512 words. So, I think that the source, where you read your data, can only provide 512 bytes of data. It does not depend on the size of your buffer that you use. :D
I hope this make sense. ;)Last edited by tim; 02-07-2008 at 01:38 PM.
Eyes dwelling into the past are blind to what lies in the future. Step carefully.
- 02-07-2008, 01:43 PM #4
Member
- Join Date
- Feb 2008
- Posts
- 3
- Rep Power
- 0
You're correct, I'm acting as the client, not the server. My bad.
I've written the code for the Server myself, in another language (NetLinx). I'm fairly confident that it is sending significantly more than 512 bytes. This doesn't seem to jive with what you're suggesting . . . .
I'll play with it a bit more and see if that appears to be the problem.
J
Similar Threads
-
how to redirect the output buffer of pl/sql onto a jsp
By sriavr in forum JDBCReplies: 0Last Post: 03-11-2008, 12:25 PM -
Help needed with sizing components
By adlb1300 in forum New To JavaReplies: 2Last Post: 11-20-2007, 04:40 AM -
Http Buffer issue... chunked?
By jlew in forum NetworkingReplies: 1Last Post: 11-04-2007, 05:45 PM -
Help with String Buffer
By mathias in forum AWT / SwingReplies: 1Last Post: 08-07-2007, 06:52 AM -
how to set the value of BUFFER SIZE
By oregon in forum Advanced JavaReplies: 1Last Post: 08-06-2007, 03:16 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks