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

Nortel ntbboga-93 with Memory Card NT7B64BG mics-dr 4.1 s/w
$89.99
Nortel ntbboga-93 with Memory Card NT7B64BG  mics-dr 4.1 s/w pictureSiemens 6ES7 953-8LF20-0AA0 Memory Card Module 64kb
$30.0
Siemens 6ES7 953-8LF20-0AA0 Memory Card Module 64kb picture5Pcs DS3231 AT24C32 IIC RTC Clock Timer Memory For Arduino Replace DS1307 USA
$13.75
5Pcs DS3231 AT24C32 IIC RTC Clock Timer Memory For Arduino Replace DS1307 USA picture40x40x11mm Aluminum Heat Sink for Computer LED Power Memory Chip TSUS
$0.99
40x40x11mm Aluminum Heat Sink for Computer LED Power Memory Chip TSUS pictureDIY Precision DS3231 RTC Real Time Memory Clock Module For Raspberry Pi USA
$5.75
DIY Precision DS3231 RTC Real Time Memory Clock Module For Raspberry Pi USA picture






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