Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sockets and Hex?

Status
Not open for further replies.

devilpanther

Programmer
Oct 8, 2004
57
IL
I want to send over a socket non-readable chars, for example: 0x01

So I treid to do the next:
Code:
print $sock 0x01;

But it's not working right, the char being sent is not the one I want... it's just random junk at best.

Is there a special way to send hex values over sockets?
 
I'm not certain, but you might want to take a look at pack and unpack.
 
pack and unpack are where it's at, unless you feel like hand rolling all your own data - I'd be looking at pack/unpack ;-)

Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
You were right, pack did the trick:
Code:
$char = pack('c', 0x22);

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top