c code to make a socket mirror (loopback)
Hello!
I ` am not to good on c so I`ll need your help. I need a socket loopback programm, which sends data to a socket and also listens if there is something send back. So a loopback. I found this programm http://www.pronix.de/pronix-275.html which actually works fine, in sending the data but it does not recieve data (as it is only designed as a client). I read on that page (only german, sorry for that) that there a two options. a) write() b) read() So I tought that i would only have to add a read (...) so i get the data which is send from the loop-back-device. But I am not sure how that line should look or where i must add that line. I used: socket (AF_INET, SOCK_STREAM, 0) to open the socket so that should be bidirectional, not ? |
The code does receive the data, but it then uses it to read user input (fgets). Use two different buffers and it should be fine. The socket created using socket (AF_INET, SOCK_STREAM, 0) is definitely bidirectional.
You may want to use non-blocking socket and/or select later, however, if blocking becomes a limitation (check further examples in your tutorial). |
Ah, well ok!
I got it working! maybe the code: Quote:
|
All times are GMT -5. The time now is 04:51 PM. |