Buffers in c++ ANYONE HELP ME!!!!

W

williamcorrea85

hi, I`m doing an application where I use sockets to connect two
differentes machines, but I don`t know how to create the buffers to
receive and to send data
 
G

Gianni Mariani

hi, I`m doing an application where I use sockets to connect two
differentes machines, but I don`t know how to create the buffers to
receive and to send data

an "array of char" will do. In fact, you can use a std::vector<char>
and size it to the size you want to read (or more).
 
S

Sharpen

hi, I`m doing an application where I use sockets to connect two
differentes machines, but I don`t know how to create the buffers to
receive and to send data

you define a structure , and set value to the member of this object of
structure,and write code like
"send(s,&your_object_of_structure,sizeof(your_object_of_structure),0)"
 
J

Jim Langston

hi, I`m doing an application where I use sockets to connect two
differentes machines, but I don`t know how to create the buffers to
receive and to send data

It all depends on what you plan on doing with the buffer. If you plan on
filling it, then passing it to something else, a std::string should be fine.
If you need to buffer messages by some code or something, maybe a
std::vector<std::string>.

A lot of it just depends.
 
K

kwikius

It all depends on what you plan on doing with the buffer. If you plan on
filling it, then passing it to something else, a std::string should be fine.
If you need to buffer messages by some code or something, maybe a
std::vector<std::string>.

There is also std::queue, and std::streambuf, the first can be used
direct as a fifo container or as an interface example for say a fixed
size buffer using an array. The second may provide a base class for
the interface for a buffer.


I think Boost.Asio covers this sort of ground, so may be worth
investigating too:

http://tinyurl.com/yq3cc2

That said I have never had much dealings with any of the above...


regards
Andy Little
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top