Assuming by "record it" you mean you want to write it to a file, then yes, it's pretty easy. Unix has had a tee
utility for years that would let you do something like:
gateway_listener | tee record_file
If you're running on a system that doesn't provide a tee
by default, it should be pretty easy to find or compile one:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
FILE *outfile;
int c;
if ( argc < 2) {
fprintf(stderr, "Usage: tee <out_file>\n");
return EXIT_FAILURE;
}
if (NULL == (outfile = fopen(argv[1], "w"))) {
fprintf(stderr, "Unable to open '%s'\n", argv[1]);
return EXIT_FAILURE;
}
while (EOF != (c=getchar())) {
putc(c, outfile);
putchar(c);
}
fclose(outfile);
return 0;
}