如何用TCL实现一个FTP客户端?
我可以建立一个21端口的连接,但20端口就不会搞了。请高手帮助!先谢过了!#################Creat Socket proc
proc Socket_client { host port timeout} {
global connected
after $timeout {set connected timeout}
set sock
fileevent $sock w {set connected ok}
vwait connected
if { $connected == "timeout" } {
return -code error timeout
} else {
return $sock
}
}
###############Login
proc Login {Lsock21 Username Pass} {
puts $Lsock21 "USER $Username"
puts
puts $Lsock21 "PASS $Pass"
set loginSucc
if {$loginSucc == {230 User logged in}} {
return 1
} else {
return 0
}
}
#############server accept
proc Accept {newSock addr port} {
puts "Accepted $newSock from $addr port $port"
}
proc Socket20_Client {listenport} {
set listensocket
vwait listensocket
ruten $listensocket
}
#############Main Proc
#############FTP port 21 connection
set sock21
fconfigure $sock21 -buffering line
puts
set Login21 a@b.com}]
set socketMsg
set localport
set portHi [ expr round( ($localport + 2) / 256)]
set portLo [ expr round( fmod($localport, 256))]
puts $sock21 "port 10, 21, 4, 16, $portHi, $portLo"
puts $sock21 {NLST}
#set socket20 ]
puts $sock21 {}
after 1000 {
#puts
#set sock2102
#puts $sock2102
#set sock1
#puts
#close $sock21
#close $sock1
} 你是用Socket来做???好很不简单啊。。
你可以用Expert来做。。那个比较简单。。 请教:
c写个unix socket ,如何用tcl加载 C语言写的扩展包?
页:
[1]