Path: utzoo!attcan!uunet!aplcen!uakari.primate.wisc.edu!uflorida!mlb.semi.harris.com!thrush.mlb.semi.harris.com!del From: del@thrush.mlb.semi.harris.com (Don Lewis) Newsgroups: comp.protocols.tcp-ip Subject: Re: sockets vs. streams Message-ID: <1990Sep7.043303.21129@mlb.semi.harris.com> Date: 7 Sep 90 04:33:03 GMT References: <2350@cirrusl.UUCP> <1990Sep5.020521.803@mlb.semi.harris.com> <2364@cirrusl.UUCP> Sender: news@mlb.semi.harris.com Organization: Harris Semiconductor, Melbourne FL Lines: 53 In article <2364@cirrusl.UUCP> dhesi%cirrusl@oliveb.ATC.olivetti.com (Rahul Dhesi) writes: >Don Lewis writes: > > Now, if the printer is on a terminal server somewhere... > cat somefile >/dev/tcp/x.x.x.x-y.y > > Specifically, you could use this for the lp= parameter in > /etc/printcap... > >This would be nice. A possible solution is to write a program "netsend": > > cat somefile | netsend tcp:x.x.x.x-y.y > >Since printcap allows sending to a filter rather than a specific >device, the solution is general enough. This is not enough if you need to use the `of' filter. Lets say you specify both the `if' and `of' filters and lpr a simple text file. Lpd opens the printer device, forks and execs a copy of the `of' filter with its stdout connected to the printer and its stdin connected to a pipe back to lpd. Lpd then squirts the banner down the pipe to the `of' filter followed by ^Y^A. When the `of' filter sees the ^Y^A, it flushes stdout and sends itself a STOP signal. Lpd sees the `of' filter stop and then forks and execs a copy of the `if' filter which has its stdout connected to the printer and its stdin connected to the file to be printed. Once the `if' filter exits, lpd sends a CONT signal to the `of' filter and writes either the banner for the next job or the trailer string to it. For different print file formats, substitute the appropriate filter for the `if' filter. If the particular device you are using needs the functionality of the `of' filter, you can't just put a shell wrapper that pipes its output to netsend because there is no way for the `if' filter to make a connection to the printer as long as the `of' filter is running (also, the link between `of' and the printer may need to be bidirectional). If you don't need `of', you may be able to do this with `if', but you will not be able the banner and trailer because lpd wants to send these to the printer before/after running `if'. There are possible workarounds using pty's or named pipes with daemons on the other side or passing the fd to the socket through unix domain sockets, but YUCK! If the device is something wierd and you don't have the source for the filters then you are in pretty deep trouble. Why should it take a wizard to switch a printer from a serial port to a terminal server? -- Don "Truck" Lewis Harris Semiconductor Internet: del@mlb.semi.harris.com PO Box 883 MS 62A-028 Phone: (407) 729-5205 Melbourne, FL 32901