I have an existing C program which prints a number of messages to standard error using:
fprintf(stderr, ...
I would like to modify this program so that these messages are also sent out over a TCP connection across the Internet. (Which I have already created as a SOCK_STREAM socket.) What's the best way format the messages like they would be by fprintf and then send them out across the Internet?
Of course, before I can send a message I first need to know how long it is, so I can send the length out to the client first, so the client will know how many bytes to read in...
Any ideas would be most appreciated!