Results 1 to 2 of 2
Thread: Buffered Reader is missing data
- 11-11-2012, 02:16 AM #1
Member
- Join Date
- Nov 2012
- Posts
- 1
- Rep Power
- 0
Buffered Reader is missing data
As part of a program I am writing I am looking to do some MTU discovery, but the results aren't coming through. Any suggestions?
The script returns:Java Code:private static void __testMTU() { int base = 0; int limit = _length; int attemptNumber = 1; int attempt = 0; boolean isFragmented = false; while(base!=limit){ if(attemptNumber!=1){ attempt = (base+limit)/2; } else { attempt = limit; } String stmt = "ping "; if(_OS.equalsIgnoreCase("win")){ stmt += "-n 1 -f -l "+attempt+" "+_target; } else if (_OS.equalsIgnoreCase("mac") || _OS.equalsIgnoreCase("nix")){ stmt += "-c 1 -s "+attempt+" -D "+_target; } else { _summary += "MTU can not be tested on a Solaris system as the ping utility does not support the Do Not Fragment Flag."; break; } try { Process p=Runtime.getRuntime().exec(stmt); p.waitFor(); BufferedReader reader=new BufferedReader(new InputStreamReader(p.getInputStream())); _summary += stmt+"\n"; String line=reader.readLine(); while(line!=null) { _summary += line+"\n"; if(line.lastIndexOf("truncated") >= 0 || line.lastIndexOf("fragmented") >= 0 || line.lastIndexOf("too long") >= 0) { isFragmented = true; } line=reader.readLine(); } } catch(Exception e) {} if(attemptNumber==1 && !isFragmented) { break; } if(attemptNumber==1 && isFragmented) { _summary += "Your packet size exceeds the MTU for this connection and will be adjusted to equal the maximum MTU possible."; } if(isFragmented){ limit = attempt; } else { base = attempt; } attemptNumber++; } _length = base; }
but executing the command from the terminal returns:ping -c 1 -s 64565 -D Google
PING Google (74.125.130.103): 64565 data bytes
--- Google ping statistics ---
1 packets transmitted, 0 packets received, 100.0% packet loss
I really need that Message too long statement. :)localhost:bin john$ ping -c 1 -s 64565 -D Google
PING Google (74.125.130.103): 64565 data bytes
ping: sendto: Message too long
--- Google ping statistics ---
1 packets transmitted, 0 packets received, 100.0% packet loss
- 11-11-2012, 08:26 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,427
- Blog Entries
- 7
- Rep Power
- 17
Re: Buffered Reader is missing data
You're waiting for another process to complete and only then are you trying to read its output. Don't wait for its completion (its output buffer might fill up) but start reading its output right away.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
Buffered reader
By franckboy in forum New To JavaReplies: 1Last Post: 02-02-2011, 07:16 PM -
Buffered Reader
By ilovepolluting in forum New To JavaReplies: 2Last Post: 02-04-2010, 09:16 AM -
Buffered Reader problem
By pradeep.theonlyone in forum New To JavaReplies: 3Last Post: 07-31-2009, 11:37 AM -
Buffered Reader Exception
By hitmen in forum New To JavaReplies: 6Last Post: 01-07-2009, 11:14 AM -
FileReader / Buffered Reader
By sepaht in forum New To JavaReplies: 9Last Post: 07-10-2008, 08:05 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks