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

Discussion in 'C++' started by williamcorrea85@gmail.com, Mar 13, 2007.

  1. Guest

    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
    , Mar 13, 2007
    #1
    1. Advertising

  2. wrote:
    > 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).
    Gianni Mariani, Mar 13, 2007
    #2
    1. Advertising

  3. Sharpen Guest

    On Mar 14, 4:10 am, wrote:
    > 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)"
    Sharpen, Mar 14, 2007
    #3
  4. Jim Langston Guest

    <> wrote in message
    news:...
    > 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.
    Jim Langston, Mar 18, 2007
    #4
  5. kwikius Guest

    On 18 Mar, 07:42, "Jim Langston" <> wrote:
    > <> wrote in message
    >
    > news:...
    >
    > > 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>.


    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
    kwikius, Mar 18, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Oleg
    Replies:
    4
    Views:
    6,792
    Ray Andraka
    Apr 6, 2004
  2. ratep2001

    Delay with buffers

    ratep2001, Feb 25, 2005, in forum: VHDL
    Replies:
    3
    Views:
    4,081
    cristian
    Feb 28, 2005
  3. Replies:
    2
    Views:
    484
  4. Tim Greenfield

    WriteFile buffers in memory

    Tim Greenfield, Oct 4, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    2,083
    Tim Greenfield
    Oct 5, 2004
  5. RogerTBrick

    Buffers with included pages

    RogerTBrick, May 12, 2004, in forum: Java
    Replies:
    4
    Views:
    628
    RogerTBrick
    May 18, 2004
Loading...

Share This Page