archie/tcl-dp/tests/xmit.test

101 lines
2.3 KiB
Plaintext
Raw Permalink Normal View History

2024-05-27 16:13:40 +02:00
# xmit.test
#
# This file tests the dp_send/dp_recv commands and large packet
# transmissions.
#
# Large datagram transmissions are somewhat of a black box. It's
# hard to predict what any given OS or Tcl will do if you don't read the
# entire input. NT hangs. HP-UX just truncates the datagram to the
# Tcl buffer size.
#
# In the cases below, we are setting the Tcl buffer to 8192. The
# actual sockets should have a buffer of 8192 also. We then send
# and recv 10,000 bytes over the connection.
#
if {[string compare test [info procs test]] == 1} then {source ../tests/defs}
set sock1 {}
set sock2 {}
set a 0123456789
set h $a$a$a$a$a$a$a$a$a$a
set t $h$h$h$h$h$h$h$h$h$h
set w $t$t$t$t$t$t$t$t
# NOTE
# w is now only 8,000 bytes long. I don't have time to debug it.
#
test xmit-1.1 {udp send/recv} {
list [catch {
set sock1 [dp_connect udp -host localhost -port 1999 -myport 2000]
set sock2 [dp_connect udp -host localhost -port 2000 -myport 1999]
dp_send $sock1 "Hey there!"
dp_recv $sock2
} msg] $msg
} {0 {Hey there!}}
test xmit-1.2 {huge udp send/recv} {
list [catch {
fconfigure $sock1 -buffersize 8192
fconfigure $sock2 -buffersize 8192
puts $sock1 $w
string compare [gets $sock2] $w
} msg] $msg
} {0 0}
catch {close $sock1}
catch {close $sock2}
test xmit-1.3 {tcp send/recv} {
list [catch {
set server [dp_connect tcp -server 1 -myport 2906]
set sock1 [dp_connect tcp -host localhost -port 2906 -async 1]
after 200
set sock2 [lindex [dp_accept $server] 0]
dp_send $sock1 "Hey there!"
dp_recv $sock2
} msg] $msg
} {0 {Hey there!}}
test xmit-1.4 {huge tcp send/recv} {
list [catch {
fconfigure $sock1 -buffersize 8192
fconfigure $sock2 -buffersize 8192
puts $sock1 $w
string compare [gets $sock2] $w
} msg] $msg
} {0 0}
catch {close $server}
catch {close $sock1}
catch {close $sock2}
# See ipm.test for why this is necessary
#
if {$ipm == 1} {
test xmit-1.5 {ipm send/recv} {
list [catch {
set sock1 [dp_connect ipm -group 225.5.5.5 -myport 2000]
dp_send $sock1 "Hey there!"
dp_recv $sock1
} msg] $msg
} {0 {Hey there!}}
test xmit-1.6 {huge ipm send/recv} {
list [catch {
fconfigure $sock1 -buffersize 8192
puts $sock1 $w
string compare [gets $sock1] $w
} msg] $msg
} {0 0}
catch {close $sock1}
catch {close $sock2}
}