summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.samples/tcptest.tcl
blob: 18d92593143cef60c1ac396c1539e852f7e40501 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/tclsh

set host            localhost 
set port            11900

proc receiver {sock addr port} {
   fconfigure $sock -encoding binary -buffersize 16
   while {[read $sock 16] != {}} { }
   exit
}

proc sender { } {
   set tst_str      "1234567890123456"
   after 2000
   while {[catch {set sock [socket $::host $::port]}]} {}
   fconfigure $sock -encoding binary -buffersize 16
   for {set i 6400} {$i > 0} {incr i -1} {
      puts -nonewline $sock $tst_str;
   }
   return 0 
}

if {[llength $argv] == 0} { 
   socket -server receiver $port
   after 30000 set thirty_secs timeout 
   vwait thirty_secs 
} else {
   exec $argv0 &
   sender 
}