473,383 Members | 1,855 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

C# - buffer byte array

hi there,
i playing around with an async server, i use BeginReceive with byte array to store incoming data, when a "big" data come, a call back receive can not read it all in one time, so i need repeat call back, i want know how to cache all incoming data in byte array? like byte buffer class in java

searching..., seem they will do: convert a part of data (in byte array) to string and use StringBuilder to store it, append next part in next call back, check a flag in string to know when they received all data.

But i don't want convert byte stream to string, with byte array i can easily cast, read data from it by using MemoryStream and BinaryReader

hope you guys can help me out, thanks
Sep 10 '08 #1
2 5272
---- class object variables
//your data buffer is created here
byte[] m_byteReadData = new byte[0];


----Read data callback
// data is returned in l_byteReceivedData array

byte[] l_byteTemp = new byte[m_byteReadData.Length];
m_byteReadData.CopyTo(l_byteTemp,0);
m_byteReadData = new byte[l_byteTemp.Length + l_byteReceivedData.Length];
l_byteTemp.CopyTo(m_byteReadData,0);
l_byteReceivedData.CopyTo(m_byteReadData,l_byteTem p.Length);

that is just one sample solution you can use Qeue, or Array object...
Sep 12 '08 #2
Plater
7,872 Expert 4TB
How about a generic? List<byte> or LinkedList<byte> maybe?
Sep 12 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Denis C | last post by:
Hi, I posted this earlier today with no help. I'm trying agin as I am desparate(sp?). Hi there, I'm trying to convert part of a byte array into a series of fixed length strings but half...
5
by: David | last post by:
I note that you can null teminate a string by adding controlchar.null. Is there a way of adding a null to a Buffer of Bytes and converting it to a string. I have packets coming in from a...
1
by: JC | last post by:
HI I want to use a byte array to store all the content of a file. Is there anyway allow me to do so? Thx JC
9
by: Burkhard | last post by:
I declared a struct with fixed size buffers to send it to an unmanaged function unsafe struct RCSTKAS { public fixed Byte xValue1 ; public fixed Byte xValue2 ; ... }
28
by: bwaichu | last post by:
Is it generally better to set-up a buffer (fixed sized array) and read and write to that buffer even if it is larger than what is being written to it? Or is it better to allocate memory and...
1
by: Damir Dezeljin | last post by:
Hi. I'm developing an application using managed C++. My application has to use a DLL developed in standard C++. The mentioned DLL implements a class for file operations. There is a class method...
0
by: vinbelgian | last post by:
I have some trouble with making a buffer in vb.net. I use a C dll that requires me to give him a pointer to a buffer of bytes where he is going to write bytes to, depending on the command i...
0
by: shofu_au | last post by:
Hi Group, I am trying without much luck to pack messages into a byte buffer using get and set accessors. I have attached a simplified example of what I am trying to do using byte variables....
2
by: =?Utf-8?B?QmFydE1hbg==?= | last post by:
Greetings, I am working on a project where the interface from the UI application (done in C#) requires that an image buffer be passed back as a byte array as defined by an interface. The...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.