I have two variables: buf and length (char buf[BUFSIZE], int length). Buf contains DNS messages sent with UDP protocol and in length there is length of that message. Now I need to change buf so I can use it with TCP protocol and send it to DNS server and get response and that response change back to UDP protocol.
I know I should add some bytes and then delete some bytes but I really don´t know which one. So please help and please show it in C too.
You need to open a second socket of type SOCK_STREAM and then use send() to send the content of
buf:This works because when working with sockets, you usually don’t get the protocol headers, just the UDP/TCP payload.