examples/pcap-pop3-demo.ss
#!/bin/sh
#|
exec mzscheme -u "$0" "$@"
|#

(module pcap-pop3-demo mzscheme
  (require "../SPeaCAP.ss")
  
  (call-with-open-offline 
   (build-path (current-directory) "pop3.pcap")
   (lambda (pcap)
     (set-filter! pcap (compile-filter pcap "tcp dst port 110"))
     (dispatch pcap +inf.0 
               (lambda (head data breakloop)
                 (let ((payload (subbytes data 56)))
                   (if (regexp-match "^USER|^PASS" payload)
                       (printf "~a" (bytes->string/utf-8 payload #\?))))))))
  
  )