如何生成原始数据? [英] how to generate raw data?

查看:216
本文介绍了如何生成原始数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

工具:

*操作系统:Win XP,
* MSVC ++

问题是我想生成一些原始数据"流,即我的意思是一个随机的1和0的流,接下来,我想通过udp套接字发送此生成的流.

关于如何生成该流的任何想法?

我希望我的问题很清楚,并在此先感谢

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

推荐答案

您需要使用位计数字段和包含位的字节数组来创建消息,因为您不能只发送一个位,然后再在UDP数据包中发送所有这些位.如果您只发送8位的倍数,则即使需要发送计数字段也不需要发送计数字段.
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.




在VC2010中,使用 std :: uniform_int [
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


这篇关于如何生成原始数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆