Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tcl_MakeFileChannel/Tcl_RegisterChannel use to add file descriptor?

50 views
Skip to first unread message

Frank Goenninger DG1SBG

unread,
May 17, 2006, 5:31:55 AM5/17/06
to
Hi all:

(working on OS X, using Lisp to call Tcl/Tk via the C API)

I do have the problem of adding a file descriptor I've got for a file
to the interpreter's channel list.

I want to be able to do

(in Tcl, fd = file descriptor)

fileevent fd readable [list my-function fd]

I tried to do the following:

(in C)

Tcl_RegisterChannel( interp, Tcl_MakeFileChannel( fd, TCL_READABLE ));

Still, when using the fileevent statement as shown above I get an
error saying

can not find channel "17"

(17 being the file descriptor I tried to register)

Anyone? Thx!!!

Frank

Michael Schlenker

unread,
May 17, 2006, 5:49:08 AM5/17/06
to
Frank Goenninger DG1SBG schrieb:
Did you check the return value of Tcl_MakeFileChannel?

You should probably use Tcl_GetChannelName() on the result of
Tcl_MakeFileChannel() to get the name of the channel, as fileevent needs
this for its operation.

Michael

Bryan Oakley

unread,
May 17, 2006, 8:00:48 AM5/17/06
to
Frank Goenninger DG1SBG wrote:
> I tried to do the following:
>
> (in C)
>
> Tcl_RegisterChannel( interp, Tcl_MakeFileChannel( fd, TCL_READABLE ));
>
> Still, when using the fileevent statement as shown above I get an
> error saying
>
> can not find channel "17"

I don't know the C api, but "17" doesn't look like a valid channel name
to me. For instance, when I do an open via tcl I'll get back something
that looks like "file15".

Perhaps you need to convert your raw file descriptor into a tcl channel
name somehow.

--
Bryan Oakley
http://www.tclscripting.com

Frank Goenninger DG1SBG

unread,
May 17, 2006, 4:09:34 PM5/17/06
to
Bryan Oakley <oak...@bardo.clearlight.com> writes:

Thanks, yes, that was the problem with this piece of code.

But now I am working on the fact that Tcl_RegisterChannel segfaults
...

Any special experience here ?

Thx!

Frank

0 new messages