Sending Hex to sockets? [Archive] - C Board

PDA

View Full Version : Sending Hex to sockets?


chrisjmoss
04-03-2008, 05:43 AM
Hi guys i'm writing a UDP client based on the example given in TCP/IP sockets in C book, but I would like to know how to send a hex string to the socket.

Currently when I write a hex string it is interpreted as ascii, but I would like it to be sent as it is written. Do I need to do ascii to hex conversion on the commandline argument or is it relating to the socket iteself.

All help is greatly appreciated

matsp
04-03-2008, 05:50 AM
Considering that sending binary data across the network is subject to byte-order, isn't sending a hex-string actually a better choice anyways?

Edit: Obviously at some point, the hex string will need to be translated to a binary value - but I would prefer to do that where it's being used, rather than the client side. It's obviously a subject that can only be determined on a personal preference basis.

--
Mats