Re: Desperately need help in Tcl socket and fileevent puzzle...
From: Donal K. Fellows (donal.k.fellows_at_man.ac.uk)
Date: 08/19/04
- Next message: Randolf Schultz: "Re: togl on windows: number of creatable OpenGL widgets?"
- Previous message: Ralf Fassel: "togl on windows: number of creatable OpenGL widgets?"
- In reply to: Mike: "Desperately need help in Tcl socket and fileevent puzzle..."
- Next in thread: Mike: "Re: Desperately need help in Tcl socket and fileevent puzzle..."
- Reply: Mike: "Re: Desperately need help in Tcl socket and fileevent puzzle..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 19 Aug 2004 11:11:57 +0100
Mike wrote:
> I have a small program in TCL that:
> 1) connect to a socket
> 2) setup a fileevent handler to read binary data coming from this
> socket
Did you remember to put:
fconfigure $channel -translation binary
in there? Without that, it won't work.
> When binary data received
> 2a) The handler does: set binStream [read $channel]
> 2a) the handler then appends this "binStream" to a file:
> puts -nonewline $binFile $binStream
You'll want to also make the $binFile channel a binary channel.
> Looking at the content of the binary file logged in (2a), the content
> was 100% correct. However, the proc that processes the data (4) got
> corrupted data from time to time from the result of "binary scan" when
> it parsed "binStreamCopy".
Ah, let me guess. You're running on Windows? Or possibly OSX?
The problem is end-of-line translation, and putting in suitable
[fconfigure] invokations (see above for an example) will fix it (and a
few other things that you've luckily not hit so far). If you're
processing the data in a command written in C, there are a few other
issues you might want to bear in mind, but you don't seem to be
indicating that that's the case here.
Donal.
- Next message: Randolf Schultz: "Re: togl on windows: number of creatable OpenGL widgets?"
- Previous message: Ralf Fassel: "togl on windows: number of creatable OpenGL widgets?"
- In reply to: Mike: "Desperately need help in Tcl socket and fileevent puzzle..."
- Next in thread: Mike: "Re: Desperately need help in Tcl socket and fileevent puzzle..."
- Reply: Mike: "Re: Desperately need help in Tcl socket and fileevent puzzle..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|