• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 238
  • Last Modified:

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

thx
0
turbot_yu
Asked:
turbot_yu
  • 3
  • 2
2 Solutions
 
itsmeandnobodyelseCommented:
>>>> 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
 
turbot_yuAuthor Commented:
is there any detail explain of it, or any samples.
0
 
itsmeandnobodyelseCommented:
>>>> 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
 
turbot_yuAuthor Commented:
I just want to learn the basic structure for tcp program of software bus,

I totally do not have ideas of it.
0
 
itsmeandnobodyelseCommented:
>>>> tcp program of software bus

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



0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now