Click here to Skip to main content
15,949,686 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Unique number from two numbers Pin
harold aptroot15-May-10 5:43
harold aptroot15-May-10 5:43 
GeneralRe: Unique number from two numbers Pin
Luc Pattyn15-May-10 6:00
sitebuilderLuc Pattyn15-May-10 6:00 
GeneralRe: Unique number from two numbers Pin
CPallini18-May-10 1:52
mveCPallini18-May-10 1:52 
GeneralRe: Unique number from two numbers Pin
CPallini17-May-10 22:37
mveCPallini17-May-10 22:37 
GeneralRe: Unique number from two numbers Pin
theCPkid18-May-10 1:39
theCPkid18-May-10 1:39 
GeneralRe: Unique number from two numbers Pin
CPallini18-May-10 1:45
mveCPallini18-May-10 1:45 
QuestionSocket message(frame) pattern matching Pin
Hamed Musavi13-May-10 7:42
Hamed Musavi13-May-10 7:42 
AnswerRe: Socket message(frame) pattern matching Pin
Luc Pattyn13-May-10 7:55
sitebuilderLuc Pattyn13-May-10 7:55 
Hamed Mosavi wrote:
matching packets


I see nothing to match; you said the message would start with a size, so the first 1/2/4/? bytes should be aggregated into a size value (maybe BitConverter.ToInt32 comes in handy), then that number of bytes of data are expected, then the next 1/2/4/? bytes should be aggregated into a checksum value, which when it matches the local checksum calculation will make the message acceptable, otherwise unacceptable.

You may apply extra checks, such as upper/lower limits to datasize. When multiple systems (and maybe multiple implementations) are going to be used, you should carefully specify the checksum algorithm used, and the byte order ("endianness") in multi-byte values (probably size and checksum).

If you need syncing capabilities (e.g. because some bytes may get lost underway), you should start with a fixed header, sometimes called an eye catcher, akin to the start bit of RS232C. Then your receiver should check the data starts with a correct header, and ignore anything that does not.

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

I only read formatted code with indentation, so please use PRE tags for code snippets.

I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).

GeneralRe: Socket message(frame) pattern matching Pin
Hamed Musavi13-May-10 8:21
Hamed Musavi13-May-10 8:21 
GeneralRe: Socket message(frame) pattern matching Pin
Luc Pattyn13-May-10 8:31
sitebuilderLuc Pattyn13-May-10 8:31 
GeneralRe: Socket message(frame) pattern matching Pin
Hamed Musavi13-May-10 8:55
Hamed Musavi13-May-10 8:55 
GeneralRe: Socket message(frame) pattern matching Pin
Luc Pattyn13-May-10 9:05
sitebuilderLuc Pattyn13-May-10 9:05 
GeneralRe: Socket message(frame) pattern matching Pin
Hamed Musavi13-May-10 9:25
Hamed Musavi13-May-10 9:25 
GeneralRe: Socket message(frame) pattern matching Pin
Luc Pattyn13-May-10 9:34
sitebuilderLuc Pattyn13-May-10 9:34 
GeneralRe: Socket message(frame) pattern matching Pin
Hamed Musavi13-May-10 9:39
Hamed Musavi13-May-10 9:39 
QuestionNeed of Decision Tree Implementation Pin
Radiit6-May-10 3:05
Radiit6-May-10 3:05 
Questionfind a sulution! Pin
wbgxx3-May-10 3:59
wbgxx3-May-10 3:59 
AnswerRe: find a sulution! Pin
Kevin Drzycimski3-May-10 4:06
Kevin Drzycimski3-May-10 4:06 
GeneralRe: find a sulution! Pin
wbgxx3-May-10 4:12
wbgxx3-May-10 4:12 
GeneralRe: find a sulution! Pin
Luc Pattyn3-May-10 4:13
sitebuilderLuc Pattyn3-May-10 4:13 
GeneralRe: find a sulution! Pin
wbgxx3-May-10 4:15
wbgxx3-May-10 4:15 
AnswerRe: find a solution! Pin
theCPkid6-May-10 2:21
theCPkid6-May-10 2:21 
GeneralRe: find a solution! [modified] Pin
Radhakrishnan G.18-May-10 3:30
Radhakrishnan G.18-May-10 3:30 
GeneralRe: find a solution! Pin
talazz12-May-11 2:53
talazz12-May-11 2:53 
QuestionSimulating movement Pin
Code-o-mat24-Apr-10 5:49
Code-o-mat24-Apr-10 5:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.