Solved

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

Posted on 2006-10-22
5
229 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

831 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