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

1PCS EN2-B1N1ST Encapsulation:DIP10,Twin relay for motor and solenoid
$15.0
1PCS EN2-B1N1ST  Encapsulation:DIP10,Twin relay for motor and solenoid pictureBurkert 18x 017494E Solenoid Valve Fluid Control Unit Module Manifold Assembly
$499.99
Burkert 18x 017494E Solenoid Valve Fluid Control Unit Module Manifold Assembly pictureSMC EX140-SMJ1 Valve Manifold + 8x SQ1A31Y-5-C4 Pneumatic Solenoid Valve
$34.99
SMC EX140-SMJ1 Valve Manifold + 8x SQ1A31Y-5-C4 Pneumatic Solenoid Valve pictureHUMPHREY SOLENOID VALVE PO61 P061 PD61 LOT OF 7 AND MANIFOLD 24VDC
$99.99
HUMPHREY SOLENOID VALVE PO61 P061 PD61 LOT OF 7 AND MANIFOLD 24VDC picture NORGREN V60P527AA3000A SOLENOID VALVE 2.5VA 110/120V 14-122F 29-116PSIG
$35.0
 NORGREN V60P527AA3000A SOLENOID VALVE 2.5VA 110/120V 14-122F 29-116PSIG picture






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