Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-04-2008, 10:31 PM
Member
 
Join Date: Feb 2008
Posts: 3
Jeff is on a distinguished road
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.

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."); } }
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.

Thanks a bunch!

Last edited by Jeff : 02-04-2008 at 10:40 PM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-07-2008, 02:40 PM
Member
 
Join Date: Feb 2008
Posts: 3
Jeff is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 02-07-2008, 03:32 PM
tim's Avatar
tim tim is offline
Senior Member
 
Join Date: Dec 2007
Location: South Africa
Posts: 334
tim is on a distinguished road
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.

I hope this make sense.
__________________
If your ship has not come in yet then build a lighthouse.

Last edited by tim : 02-07-2008 at 03:38 PM.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 02-07-2008, 03:43 PM
Member
 
Join Date: Feb 2008
Posts: 3
Jeff is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to redirect the output buffer of pl/sql onto a jsp sriavr Database 0 03-11-2008 02:25 PM
Help needed with sizing components adlb1300 New To Java 2 11-20-2007 06:40 AM
Http Buffer issue... chunked? jlew Networking 1 11-04-2007 07:45 PM
Help with String Buffer mathias AWT / Swing 1 08-07-2007 08:52 AM
how to set the value of BUFFER SIZE oregon Advanced Java 1 08-06-2007 05:16 AM


All times are GMT +3. The time now is 07:13 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org