Solved

What is the structure in design a simple msg soft bus on tcp

Posted on 2006-10-22
5
231 Views
Last Modified: 2010-04-01
thx
0
Comment
Question by:turbot_yu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 39

Accepted Solution

by:
itsmeandnobodyelse earned 500 total points
ID: 17790380
>>>> a simple msg soft bus

what is a soft bus?

If you mean messages via tcp in general, the design of a struct that is a kind of container for various types of messages depends very strongly on the requirements. If you are passing text messages only - think of a chat-room - you don't need a struct but simply pass the text message as char array. Or if it more complex take that:

struct Message
{
     int size;
     int msgType;
     unsigned char buffer[1];
};

That kind of struct dynamically can be increased by allocationg the needed storage and setting the size accordingly.

Of course you may add sender and receiver information, e. g. id numbers, or page numbers if the message needs to be send in parts.

You also can pass some (class) id of the data  you are passing. By means of that id you could invoke a function via function pointer that reads the data and construct a proper class object of the required type. These kind of methods were called 'factory'. And the technique to *stream* class data to a buffer and vice versa is called 'serialising'.

Regards, Alex

0
 

Author Comment

by:turbot_yu
ID: 17793801
is there any detail explain of it, or any samples.
0
 
LVL 39

Assisted Solution

by:itsmeandnobodyelse
itsmeandnobodyelse earned 500 total points
ID: 17794221
>>>> is there any detail explain of it, or any samples.

Could you specify your requirements?

As I said, for simple text messages there is no struct needed.

0
 

Author Comment

by:turbot_yu
ID: 17795345
I just want to learn the basic structure for tcp program of software bus,

I totally do not have ideas of it.
0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 17795777
>>>> tcp program of software bus

I never heard that expression. Can you find a definition? Or a further explanation (of the term only) ?



0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question