S
Sonn Ygg
In network application, we need to fill some fields of protocol header
like below (in C):
struct hdr {
unsinged short ver;
unsinged char len;
unsinged char flg;
......
};
int main(void)
{
struct hdr hh;
hh.ver = 0x1;
hh.len = 0x2;
hh.flg = 0x3;
...
send(sock, &hh, sizeof(hh), 0);
...
}
How could I do above in Ruby because I don't find how to specify the
data type of variables or the address of variables in Ruby so far? I
will deeply appreciate if anyone gives me any hint about it? Thanks a
lot.
like below (in C):
struct hdr {
unsinged short ver;
unsinged char len;
unsinged char flg;
......
};
int main(void)
{
struct hdr hh;
hh.ver = 0x1;
hh.len = 0x2;
hh.flg = 0x3;
...
send(sock, &hh, sizeof(hh), 0);
...
}
How could I do above in Ruby because I don't find how to specify the
data type of variables or the address of variables in Ruby so far? I
will deeply appreciate if anyone gives me any hint about it? Thanks a
lot.