At 09:52 AM 4/26/00 -0400, Charles Lane wrote:
>When Perl opens the socket, it also does (paraphrasing):
> fp_read = fdopen(socket,"r");
> fp_write= fdopen(socket,"w");
>so that you can use stdio routines to read or write from the socket.
You can't do stdio to sockets on VMS. This bit me a year or so ago. I
exchanged mail with the C RTL folks, and the net result was "You can't
fdopen socket file descriptors." It's not in any POSIX standard, so it
wasn't high on their list of things to fix. (I put in a fix request, but
this was when they were working on getting the 7.2 changes into the C RTL)
>Everything going INTO the fputs routine is fine. But the extra NULs
>come out the other end.
That's OK--if you were reading from that socket you'd find that you get
back what you wrote. Bleah. One ought not print and <> from sockets.
sysread/syswrite is the way to go.
>I sure hope someone at Compaq/DEC is listening and picks this up; that
>would be the "right way" to fix the problems mentioned.
We can bug the RTL folks again.
>I can see how to do it, but it's really painful....in my_fwrite:
>
> if (fstat(fileno(dest),&s) == 0 && S_ISSOCK(s.st_mode)) {
> write(fileno(dest),src,nitm*itmsz);
> } else {
> ...the code currently in my_fwrite...
> }
>
>This works, but that damn "fstat" has to be done for *every* *single*
>print...that's a performance hit we don't really need. (my_fwrite
>doesn't know when the FILE * has been closed and reopened, and yes they
>do get reused).
Nope. Perl tags each filehandle with a type. We can wedge our own type in
there for sockets and test for it instead of using fstat. I'll see about
throwing something together.
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk