From: Carlos Date: 2006-07-12T19:49:13+09:00 Subject: Re: ruby and byte Agnieszka Figiel wrote: > Hello! > > How would you go about representing the byte type in Ruby? I have a task > where I neeed to be writing and reading bytes from a tcp socket - so for > instance I might want to send/receive an integer which is 1 byte long, > other times 4 bytes. in Java you can do that easily with the byte type, > so far I have no good idea how to do this in Ruby. Use Array#pack to put your bytes/integers/etc in a string. Send and receive strings. Use String#unpack to extract bytes/integers/etc from the string. Good luck. --