Re: Nasty problem with background fcopy from socket to stdout
- From: Bruce Hartweg <bruce-news@xxxxxxxxxx>
- Date: Fri, 14 Jul 2006 18:36:25 -0500
Mikhail Teterin wrote:
Hello!^^^^^^^^^^^^^^
I'm trying to push data from a socket to stdout using a background fcopy.
I create a server socket with the procedure ("output"), that invokes the
background fcopy as soon as the there is an incoming connection. The fcopy
is supposed to call another procedure ("done"), when it finishes:
fconfigure stdout -buffering full -encoding binary -translation binary
....
proc done {conn db bytes {e {}}} {
global ${db}_done
if {$bytes == < 100 ||
I'm not sure about any I/O errors but this expression isn't correct
are you sure that this isn't the issue?
[llength $e] > 0 && ![string match "*broken pipe* $e]} {.
puts stderr "\tSome wrong with $db: processed $bytes bytes,\
got\n\t\t$e"
}
set ${db}_done 1
}
proc output {conn db sock ip cport} {
global P
fconfigure $sock -buffersize 65536 -buffering full \
-encoding binary -translation binary
puts stderr "Proceeding to [info command fcopy]"
fconfigure stdout -buffersize 65536
fcopy $sock stdout -command [list done $conn $db]
}
socket -server "output $conn $db" 0
....
vwait ${db}_done
The fcopy fails without setting any error message (!). According to
debugger, the failure happens in around tcl8.4.13/generic/tclIO.c:7710,
which reads:
if (inPtr != outPtr) {
if (nonBlocking != (writeFlags & CHANNEL_NONBLOCKING)) {
if (SetBlockMode(NULL, outPtr,
nonBlocking ? TCL_MODE_NONBLOCKING : TCL_MODE_BLOCKING)
!= TCL_OK) {
if (nonBlocking != (readFlags & CHANNEL_NONBLOCKING)) {
SetBlockMode(NULL, inPtr,
(readFlags & CHANNEL_NONBLOCKING)
? TCL_MODE_NONBLOCKING : TCL_MODE_BLOCKING);
return TCL_ERROR;
}
}
}
}
That first SetBlockMode() fails (without setting interp->result) and I get
back the rather undescriptive error :-(
What's going on? It was working fine, when I used the foreground fcopy, but
I want to be able to continue processing events, while the fcopy is in
progress... Thanks!
-mi
- Follow-Ups:
- Re: Nasty problem with background fcopy from socket to stdout
- From: Mikhail Teterin
- Re: Nasty problem with background fcopy from socket to stdout
- References:
- Nasty problem with background fcopy from socket to stdout
- From: Mikhail Teterin
- Nasty problem with background fcopy from socket to stdout
- Prev by Date: Re: How to get a Tk widget's coordinate? How to judge mouse is on a widget or not?
- Next by Date: Windows screen saver and toplevel -use option
- Previous by thread: Nasty problem with background fcopy from socket to stdout
- Next by thread: Re: Nasty problem with background fcopy from socket to stdout
- Index(es):
Relevant Pages
|