Output line-buffered or packet-buffered

-l“ option is used to specify output line-buffered. On Unix-like Operating Systems, setvbuf() or setlinebuf() will be used (code is here):

  1. ......
  2. case 'l':
  3. #ifdef _WIN32
  4. /*
  5. * _IOLBF is the same as _IOFBF in Microsoft's C
  6. * libraries; the only alternative they offer
  7. * is _IONBF.
  8. *
  9. * XXX - this should really be checking for MSVC++,
  10. * not _WIN32, if, for example, MinGW has its own
  11. * C library that is more UNIX-compatible.
  12. */
  13. setvbuf(stdout, NULL, _IONBF, 0);
  14. #else /* _WIN32 */
  15. #ifdef HAVE_SETLINEBUF
  16. setlinebuf(stdout);
  17. #else
  18. setvbuf(stdout, NULL, _IOLBF, 0);
  19. #endif
  20. #endif /* _WIN32 */
  21. break;
  22. ......

tcpdump can also output packet-buffered through “-U/--packet-buffered“ option and call pcap_dump_flush API.