Posted to tcl by patthoyts at Sat Jul 04 00:06:49 GMT 2009view raw

  1. test zlib-9.1 "check fcopy over socket" -constraints zlib -setup {
  2. set srv [socket -server {apply {{c a p} {
  3. chan configure $c -encoding binary -translation binary
  4. puts "connect $a:$p"
  5. puts -nonewline $c [zlib gzip [string repeat a 81920]]
  6. close $c
  7. }}} -myaddr localhost 0]
  8. set file [makeFile {} test.gz]
  9. } -body {
  10. lassign [chan configure $srv -sockname] addr name port
  11. puts "listen $addr $port"
  12. set s [socket $addr $port]
  13. chan configure $s -encoding binary -translation binary
  14. set f [open $file wb]
  15. puts "opened $s $f"
  16. fcopy $s $f
  17. puts "copied"
  18. close $s ; close $f
  19. file size $file
  20. } -cleanup {
  21. close $srv
  22. removeFile $file
  23. } -result {x}