BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 10-06-2005, 03:02 PM   #1 (permalink)
New Member
 
Join Date: Sep 2005
Model: 7250
Posts: 10
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default readline from a socket connection

Please Login to Remove!

I have an app I'm working on which needs to read lines of text from a socket connection, delimited by carriage returns. What's the most efficient way to do that? I'm using DataInputStream. I see how to read individual bytes, which I wanted to avoid, and I see how to read x characters at a time, which seems to be missing carriage returns altogether. Is reading byte-by-byte my only option here? Isn't that rather slow?
Offline  
Old 10-06-2005, 03:40 PM   #2 (permalink)
Thumbs Must Hurt
 
Join Date: Apr 2005
Location: Portland, OR., USA
Model: 9800
Carrier: AT&T
Posts: 82
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you want a readLine function, then you would need to read byte by byte so you could stop at a EOL and the function then returns all characters up to the EOL. Typically, a readLine() does not include the EOL characters themselves.

If you want to read a chunk of data, then you would have to read all the server data and split up the big chunk into its individual lines. If you stopped once you found an EOL in your chunk, then your reader routine would have to save the remaining chars (after the EOL) so it could append its next read. This would not be a good approach.

As for byte by byte reading being slow. I believe the byte read would be occuring on a buffer of data that was sent down from the server, and not doing a byte read request back to the server.

Regards,
Eric
Offline  
Closed Thread


Thread Tools

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

UU1: Vintage Apple Powerbook Low Power AC Adapter ADP-17AB
$24.99
UU1: Vintage Apple Powerbook Low Power AC Adapter ADP-17AB pictureVintage Hammermill Continuous Feed Thermal Transfer Printer Paper Apple Scribe
$49.99
Vintage Hammermill Continuous Feed Thermal Transfer Printer Paper Apple Scribe pictureVintage Jaffrey Mfg. Co. Apple Grinder Fruit Press Cast Iron
$120.0
Vintage Jaffrey Mfg.  Co. Apple Grinder Fruit Press Cast Iron  picture2 Brand New APPLE IMAGEWRITERS - BLACK RIBBON, Vintage
$5.0
2 Brand New APPLE IMAGEWRITERS - BLACK RIBBON, Vintage pictureApple Macintosh IIcx M5850 - Vintage
$36.44
Apple Macintosh IIcx M5850 - Vintage picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.