> Hi!
>
> On Mon, 9 Jan 1995 10:11:45 +0000 (GMT),
> Ross Wakelin <rossw@march.co.uk> said:
>
> Ross> scotty tcp command
> Ross> there is a "problem" related to the tcp command in
> Ross> scotty. In the SVR4 environment, "files" are streams
> Ross> based, including socket connections. The tcp command
>
> This one is interesting. I am not sure if the streams emulation is
> wrong here or if it is just a problem with the FILE implementation of
> various C libraries. Scotty uses setbuf() to set the FILE buffer to
> zero and hence every access to the FILE handle should result in a
> read() or write() on the underlying socket. Can you check, if an
> intervening flush on the tcp file handles works just like the seek
> you were using?
>
> My experiments showed that mixed gets/puts work fine on ULTRIX-4.4,
> HP-UX-A.09.03, SunOS-4.1.3 and Linux-1.1.78. An AIX-2 box did not run
> my test, but it did when I called flush between gets and puts. Here is
> my test script:
> Could you please run this script and send me an email if it produces
> any output? Perhaps we can fix this somewhere in tcl if it is a common
> problem. Or are there some other ideas how to fix it in scotty?
>
Here is the output from the test script. As you can see, the "Bad file
number" error has appeared. The "advice" about the seek between
gets/puts in in the man page on this platform (see below)
Script started on Mon Jan 16 13:13:03 1995
# /opt/src/tcl/scotty-test
Error: error writing "file5": Bad file number
error writing "file5": Bad file number
while executing
"puts $B it"
(procedure "getsputs" line 8)
invoked from within
"getsputs """
invoked from within
"if {[getsputs ""] == "does it work ?"} {
exit
}"
(file "/opt/src/tcl/scotty-test" line 20)
#
script done on Mon Jan 16 13:13:14 1995
Man page for fopen (also fdopen, which is what tcl does)
fopen(3S) (C Programming Language Utilities) fopen(3S)
NAME
fopen, freopen, fdopen - open a stream
SYNOPSIS
#include <stdio.h>
FILE *fopen (const char *filename, const char *type);
FILE *freopen (const char *filename, const char *type, FILE
*stream);
FILE *fdopen (int fildes, const char *type);
DESCRIPTION
fopen opens the file named by filename and associates a
stream with it. fopen returns a pointer to the FILE
structure associated with the stream.
When a file is opened for update, both input and output may
-> be done on the resulting stream. However, output may not be
-> directly followed by input without an intervening fflush,
-> fseek, fsetpos, or rewind, and input may not be directly
-> followed by output without an intervening fseek, fsetpos, or
-> rewind, or an input operation that encounters end-of-file.
Ross
Ross Wakelin r.wakelin@march.co.uk
Open Systems Director
March Systems Consultancy Ltd +44 1734 304 224
or rossw@manuka.demon.co.uk at home PGP signature available