one function to send them all

This is a discussion on one function to send them all within the C++ Programming forums, part of the General Programming Boards category; Okay I have one class called landscapeClient that sends to data across a network to a server. Now, I want ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    110

    one function to send them all

    Okay I have one class called landscapeClient that sends to data across a network to a server.

    Now, I want to send several different types of classes through just one function.

    The current prototype that I have at the moment is:

    landscape client &operator<<( const messagePacket * );
    landscape client operator>>( messagePacket * );

    messagePacket is the base class that all of the different types of messages are derived from, though only part of the variables defined in the messagePacket class are sent. Thus not all of the information is getting through.

    as the aformentioned functions that are a part of the landscapeClient class only need to have the prototype changed from messagePacket * to textMessagePacket * in order to accept and send the full class.

    I have tried templating the functions, though the linker stuffs up and complains bitterly.

    Any suggestions as to how this can be fixed will be greately appreciated.

    Thanks,
    WebmasterMattD
    WebmasterMattD.NET

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    110
    Thanks for your reply.

    Would it be as simple as casting the class to a (char *) and then sending it to the function or is it more complicated than that.

    By XDR, what exactly do you mean and how does gcc/g++ handle this?

    Thanks,
    WebmasterMattD
    WebmasterMattD.NET

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    110
    How big are the classes?
    That is a hard question to answere as it is up to the user as to how much they want to store in the classes, though I will have to limit size to some degree, and then use a form of class ordering to get the information back together.

    For starters, lets say that I will limit the class size to a maximum of a couple of hundred kilooctets ( nerd talk ).

    Will look into the man pages at some stage tommorow when my brain decides to function again.

    Later,
    WebmasterMattD
    WebmasterMattD.NET

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sending n no of char data uning send() function,
    By thebrighter in forum Windows Programming
    Replies: 1
    Last Post: 08-22-2007, 12:26 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  4. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 09:18 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21