Solved

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

Posted on 2006-10-22
5
227 Views
Last Modified: 2010-04-01
thx
0
Comment
Question by:turbot_yu
  • 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now