#!/bin/sh # the next line restarts using -*-Tcl-*-sh \ exec tclsh "$0" ${1+"$@"} # records all attempts to connect to the ports listed # in the portlist. # log lines consist of a timestamp, the port number # that was connected to, and client peer info. # original version by: phil@slug.org set portlist [ list 6667 8080 31337 ] proc cfg { cid addr port } { fileevent $cid writable "handle $cid" fconfigure $cid -blocking off } proc handle { cid } { set peerinfo [ fconfigure $cid -peername ] set port [ fconfigure $cid -sockname ] close $cid set port [ lindex $port 2 ] set time [ clock seconds ] set time [ clock format $time -format "%m/%d/%y-%r %Z" ] puts stdout "$time $port $peerinfo" } foreach port $portlist { socket -server cfg $port } vwait enter-mainloop ---- See also: [fileevent] See also: [Port scanning in tcl] ---- [Category Application] | [Category Internet]