如以下结构的二进制
00 00 00 04
00 00 00 17
4D 65 73 73 61 67 65 53 76 63 2E 47 65 74 4D 73 67 56 32
其中00 00 00 04为该段字节的头部,00 00 00 17 为长度,剩余部分为内容。
C语言代码如下:

#include  <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wininet.h>

#define SIZE 1
#define BUFFER_SIZE 512
typedef struct
{
int header;
int len;
char content[BUFFER_SIZE];
} pack;

pack stu;

void main()
{
FILE *fp;
int i;
if((fp=fopen("dat.txt","w"))==NULL)
{
printf("无法打开此文件!\n");
return;
}

stu.header = htonl(4);
char content[] = {0x4D,0x65,0x73,0x73,0x61,0x67,0x65,0x53,0x76,0x63,0x2E,0x47,0x65,0x74,0x4D,0x73,0x67,0x56,0x32};
stu.len = htonl(sizeof(content)+4);
strcpy(stu.content,content);
if(fwrite(&stu, 4+4+sizeof(content), 1, fp) != 1)
printf("文件写入错误。!\n");
fclose(fp);
}

aardio语言代码如下:

import wsock

pack = {
int header;
int len;
byte content[];
}
io.open()
pack.header = wsock.htonl(4);
pack.content = '\x4D\x65\x73\x73\x61\x67\x65\x53\x76\x63\x2E\x47\x65\x74\x4D\x73\x67\x56\x32'
pack.len = wsock.htonl(#pack.content + 4)

io.print( raw.sizeof(pack ) )
re = raw.tostring( pack );
io.print( string.escape(re) );
string.save("\bin.bin",re )