URL의 내용을 파일로 저장하려는 경우 표준 http
패키지에는 -channel
옵션이있어서 직접 덤프 할 수 있습니다.
package require http
set f [open video.dump w]
fconfigure $f -translation binary
set tok [http::geturl "http://server:port/url" -channel $f]
close $f
if {[http::ncode $tok] != 200} {
# failed somehow...
} else {
# succeeded
}
http::cleanup $tok
편집 : 예를 들어 비동기 적으로 작업 수행 (vwait forever
등을 통해가는 이벤트 루프, 필요) :
package require http
set f [open video.dump w]
fconfigure $f -translation binary
proc done {f tok} {
close $f
if {[http::ncode $tok] != 200} {
# failed somehow...
} else {
# succeeded
}
http::cleanup $tok
}
http::geturl "http://server:port/url" -channel $f -command "done $f"
# Your code runs here straight away...
주를 그 코드의 알아볼 비슷하지만 지금의 약간 다른 순서 ! Tcl 8.5를 가지고 있다면 - 그렇지 않다면 왜 안됩니까? - 대신 람다 응용 프로그램을 사용하여 명백한 코드 순서를 훨씬 더 비슷하게 만들 수 있습니다.
package require http
set f [open video.dump w]
fconfigure $f -translation binary
http::geturl "http://server:port/url" -channel $f -command [list apply {{f tok} {
close $f
if {[http::ncode $tok] != 200} {
# failed somehow...
} else {
# succeeded
}
http::cleanup $tok
}} $f]
# Your code runs here straight away...
VLC가 버퍼링 할 수 있습니다. 1024 바이트 (또는 1024의 배수)를 읽으십시오. –
나는 당신의 해결책을 시도했다 ... 나는 여전히 같은 문제를 가지고있다. ... – geniecom