Click here to Skip to main content
15,899,314 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi everyone,

Tools:

* OS: Win XP,
* MSVC++

The problem is that I want to generate some "raw data" flow, by that I mean a flow of random 1s and 0s, next I want to send this generated flow over udp sockets.

any ideas on how to generate that stream?

I hope I was clear in my question and thanks in advance
Posted
Comments
Manfred Rudolf Bihy 26-Nov-10 6:11am    
I'm just being curious, but is this some experiment your doing or is it part of an use case of a real application?
fsidiosidi 26-Nov-10 8:51am    
It becomes the same if we intend to solve the problem...why? is this similar to a project you're working on?

You need to create your message using a bit count field and a byte array containing the bits, since you cannot send just a single bit, and then send all this in your UDP packet. If you only send a multiple of 8 bits, you don't need to send the count field, even though it would probably be a good idea.
 
Share this answer
 
Comments
fsidiosidi 26-Nov-10 8:52am    
but how to generate this byte array?
Hi,

With VC2010 use std::uniform_int[^] or another random generator in <random>.
With VC2008 use the same in std::tr1 namespace.
With prior compilers use int rand(); in <cstdlib>.

cheers,
AR
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900