0

How to send binascii.unhexlify data in C

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)  #OPENS NEW SOCKET
inputHex = binascii.unhexlify("1000020a4767b525156d5de2957833a5")
s.connect((ip,port))#SOCKET CONNECTION
s.send(inputHex)

my code in c

data_len = util_strlen(user_payload);
sendto(rfd, pkt, sizeof (struct iphdr) + sizeof (struct tcphdr) + data_len, MSG_NOSIGNAL, (struct sockaddr *)&targs[i].sock_addr, sizeof (struct sockaddr_in));
  • Welcome to SO. What specifically is your question? Is it just about converting the hex string into raw data for sending? Is it about sending data in general? – Gerhardh Aug 28 '22 at 09:25
  • For converting the hex string, see [Hex to char array in C](https://stackoverflow.com/questions/1557400/hex-to-char-array-in-c) – Gerhardh Aug 28 '22 at 09:26
  • @Gerhardh yes im about to send hex data to socket . i can't get it work it always send data as string – Mohamed Abdel Fattah Aug 29 '22 at 00:06
  • Did you try to use the solution from the linked question? Please edit your question to include the attempt to convert your string. See [MCVE](https://stackoverflow.com/help/mcve) for details what you should provide. – Gerhardh Aug 29 '22 at 06:18

0 Answers0