GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 28-Jan-2007, 00:10
dereliction dereliction is offline
New Member
 
Join Date: Jan 2007
Posts: 1
dereliction is on a distinguished road

Buffer size in C


HEllo all,
I need to declare a buffer that stores an incoming text message over the network from a server. The problem is, I dont know the length of this message.
I declare my buffer as char buf[8192] for example.

So right now, I read the message until the buffer gets full, and then write the contents of the buffer to a file and so on. There is an I/O involved everytime the buffer gets full.

What I;d like to do is to have some sort of infinite buffer, that would store all the message. Then I can use just one I/O to write contents of buffer into a file. Is this possible to do? Thanks.
  #2  
Old 28-Jan-2007, 02:08
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,281
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all

Re: Buffer size in C


Does your system have infinite memory? If so, yes. If not, there's a (somewhat) obvious limit.

What's wrong with what you've got? Does it not work?

Doesn't the received buffer start with the number of bytes to be read?
__________________

Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough.
-- Pearl Williams
  #3  
Old 05-Feb-2007, 18:50
msm1593 msm1593 is offline
Junior Member
 
Join Date: Jan 2007
Posts: 32
msm1593 is on a distinguished road

Re: Buffer size in C


your buffer is one "block" of data on the disk; I'm unsure if it's possible to increase or decrease the block size some how, but you could look into that

thats about all I can help
  #4  
Old 05-Feb-2007, 18:51
msm1593 msm1593 is offline
Junior Member
 
Join Date: Jan 2007
Posts: 32
msm1593 is on a distinguished road

Re: Buffer size in C


WaltP ~I think he's just trying to figure out a way to minimize disk accesses, as they take ages in computer time
 
 

Recent GIDBlogUS Elections and the ?Voter?s Responsibility? by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Hard drive/CPU Diagnoses Issues binarybug Computer Hardware Forum 1 22-Jan-2007 20:23
Determing size of a binary file Dream86 C++ Forum 7 01-Jun-2005 11:10
template comiling problems - need expert debugger! crq C++ Forum 1 01-Feb-2005 22:26
Bounded Buffering? pablowablo C Programming Language 0 17-Jan-2005 06:51
Having a problem Chuckles Computer Hardware Forum 19 13-Sep-2004 13:17

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 07:56.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.