Reaction score: 67
int fd = socket(AF_INET, SOCK_STREAM, 0); FILE *fp = fdopen(fd, "r+");
Reaction score: 2
Because this way you still can easily control how many bytes will be sent on the socket.dh said:However, I would take another path and use snprintf() to format string and use regular write() call to send it.
The way I read the OP's question, it pretty much comes down to: "How can I write to a socket instead of stdout?"dap said:bsd_newbie asked about using fprintf()
Reaction score: 7,415
Have a look at the netcat source.bsd_newbie said:I have some code that is sending output to stdout. I'd like to send it over a socket.