Networking Forums

Networking Forums > Computer Networking > Linux Networking > Bits how to program them

Reply
Thread Tools Display Modes

Bits how to program them

 
 
Marcia Hon
Guest
Posts: n/a

 
      02-11-2004, 12:28 AM
Hi,

I am writing a P2P client application. As such, I am creating packets that
are to be sent between the peers. I would like to know how in C these bits
of the packets may be programmed. These bits need to be continguous.

For example: I create a packet of size 5. 2 bytes for the size, 1 for the
message type, 1 for the start flag, 1 for the body, and 1 for the end flag.

How to I program this?

I have tried the following:

unsigned size:16;
unsigned type:8;
unsigned start:8;
unsigned body:8;
unsigned end:8;

How to I keep them contiguous? I would like to eventually send them over the
socket connection. And therefore would like to store them in an unsigned *
buffer.

Please, please help.

Thank you,
Marcia


 
Reply With Quote
 
 
 
 
Bill Unruh
Guest
Posts: n/a

 
      02-11-2004, 04:00 AM
"Marcia Hon" <(E-Mail Removed)> writes:

]Hi,

]I am writing a P2P client application. As such, I am creating packets that
]are to be sent between the peers. I would like to know how in C these bits
]of the packets may be programmed. These bits need to be continguous.

]For example: I create a packet of size 5. 2 bytes for the size, 1 for the
]message type, 1 for the start flag, 1 for the body, and 1 for the end flag.

]How to I program this?

]I have tried the following:

]unsigned size:16;
]unsigned type:8;
]unsigned start:8;
]unsigned body:8;
]unsigned end:8;

]How to I keep them contiguous? I would like to eventually send them over the
]socket connection. And therefore would like to store them in an unsigned *
]buffer.

Make a structure.

 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How many bits in a megabit? Graham J Broadband 17 12-03-2007 07:35 PM
Program Scheduler to start and end a program? Kevin Wooloff Home Networking 1 09-05-2006 04:10 PM
Bytes and bits nothere@usa.net Wireless Internet 17 05-31-2004 04:21 AM
How many bits do I want for WPA? AFN Wireless Internet 9 03-03-2004 12:46 AM
How many bits = 64? CWatters Wireless Internet 11 09-27-2003 08:11 AM



1 2 3 4 5 6 7 8 9 10 11