By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,125 Members | 1,249 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,125 IT Pros & Developers. It's quick & easy.

Transmiting data format

P: 8
Hi everyone,

I would like to transmit a stream of bits formatted to my liking, between two PCs, i already have a conection betwen them which will allow me to transmit data, an array with a string for example.

My problem is i don't have any idea as to how to go about defining the format, so that both PCs can parse it and pick out relevant information.

I need to know how to create and send frames, example:

start_bit + character + stop_bit; where the character will inclued the parity bit

I also need to know how to implement data identification, as i am sendng different types of information:

example; at one point i may ned to send, say, user_information;
which may include user_name user_password etc.

and at another time i may want to send somthing else, like, say,
system_info; which may include system_status, number_of_users, ect.

basically, the recieving PC must be able to tell:

1) what data is being sent: user or system info

2) if its user info, where does user_name stop, and user_password begin, and where does the whole user_info stop.

I am using MS visual studio .NET 2003 and programmng in C++.

If you can give some suggstions or direct me to some resource that covers this kind of thing, i would be most greatful.

Thanks very much for your attention

You are invited to be as generous as possible with your sugestions.
All suggestions welcomed.
Mar 24 '07 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 1,510
I assume you are using the serial ports of the PCs to sends bytes. What you need to do is to define a protocol or set of rules defining the communications. For example, you could send frames with a format so
frame length (byte) command (byte) data data data etc

you read the first byte with tells you the frame length and you read it into an array or vector.
The first byte of the frame then tells you what it is, e.g.
1 read a file
2 send a file
3 list a directory
etc - it all depends what you wish to do

have a look at the ftp (file transfer protocol) for an example of a protocol that has been in use for many years
Mar 24 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.