Tom Phoenix wrote: > On 12/8/07, Niu Kun <[EMAIL PROTECTED]> wrote: > >> I've got a number larger than 128. >> I want to send it by socket. >> I find that if print the number directly, I'll print the number in ascii >> format. >> So I'll have 3 separate numbers transmitted. >> But I only want to transmit one byte. >> How can I do so? > > This sounds like homework. What code have you written so far? Why are > you restricted to one byte? How large can your number be? What program > will be at the other end of the socket? What protocol does that > program support? > > --Tom Phoenix > Stonehenge Perl Training
Thank you for your reply. In fact, I'm a C programmer. And I want to write a network client program for the purpose of simulation. My network protocol is like this: String length(4 bytes, big endian) plus the real string. For simple simulate purpose, I'll limit the string length to less than 256. So I've got one byte containing the length of the string. The other end is written in C++. I‘ve got a solve method with sprintf. But I'd rather use a way more perlish.:) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/