A
akifusenet
Hi
I hope this is an OK place to ask a beginner question. Right now I am
just playing around with Ruby and IMO the best way to play around is
actually writing smtg. So I wanted to convert one of my old C programs
into Ruby. This simple program is listening on a UDP port and receives
some formatted messages send by a program. Sender program is actually
sending out a C struct. Smgt like:
typedef struct header{
UINT32 x;
UINT32 y;
UINT32 z;
} header_type;
I came upto a point in which I created an UDPSocket and recvfrom works
fine. But the received string is ofcourse cryptic. How can I convert
this byte stream into something meaningful again?
First question, how can I change network to host byte order? ( like
ntoh?)
And then how can i put this byte stream into a struct or smtg else.
(The real aim is getting x,y,z quickly)
Thanks in advance.
Akif,
I hope this is an OK place to ask a beginner question. Right now I am
just playing around with Ruby and IMO the best way to play around is
actually writing smtg. So I wanted to convert one of my old C programs
into Ruby. This simple program is listening on a UDP port and receives
some formatted messages send by a program. Sender program is actually
sending out a C struct. Smgt like:
typedef struct header{
UINT32 x;
UINT32 y;
UINT32 z;
} header_type;
I came upto a point in which I created an UDPSocket and recvfrom works
fine. But the received string is ofcourse cryptic. How can I convert
this byte stream into something meaningful again?
First question, how can I change network to host byte order? ( like
ntoh?)
And then how can i put this byte stream into a struct or smtg else.
(The real aim is getting x,y,z quickly)
Thanks in advance.
Akif,