Creating a printer emulator to capture PDL/PCL data coming in on port 9100.

I have a number of Windows CE operator terminals. They have facility to print alarms/messages to ...

  • aser or Inkjet (so they're using PCL).
  • USB or IP. IP connection takes just the IP address.

Question
How could I create a service or daemon on a server to capture all this data? Then ...

  • I would set all the terminals to print to the server IP address.
  • The server would emulate a printer (as far as the terminals are concerned).
  • The server then needs to parse and database the messages or write them to individual log files for later processing. (The individual files are so I know which terminal sent the message.)

I've learned that PCL uses port 9100 so, I presume, my service should as well.

Any pointers appreciated.

The capture process could be as simple as listening for connections on 9100 and slurping up all the data... Not positive since I haven't dealt with PCL network printers, just postscript ones, but it seems logical to guess it's a uninteractive stream since people deal with "pcl files" as well as pcl printers. That would give you raw PCL data. Once you have that, the pcltotxt tool might help you. You might have to force the print driver to output PCL5 instead of PCL6.

Thanks, Corona.

I tried using Windump - a port of tcpdump - to see if I could catch anything. I set it to listen for incoming on port 9100 but couldn't see anything. (I could see traffic if I listened for other devices on the LAN.) This caused me to think that the stream might be interactive.

Any other ideas? I'll mess around with tcpdump/Windump between to laptops and see if I can understand how it's supposed to work.

---------- Post updated at 07:32 PM ---------- Previous update was at 06:49 PM ----------

Right. Two XP laptops.

Source: 192.168.3.3, with a generic/text printer driver pointing to 192.168.3.4, port 9100.
Dest: 192.168.3.4 (Hohner) running WinDump. WinDump listening to port 9100.

Here's what I got when I try to print "Hallo World!" from Notepad on source machine ...

E:\windump>windump -i 2 -A -f -q -t -X port 9100
windump: listening on \Device\NPF_{8071A9D5-8999-472A-85C5-B1E55ABFFC9E}
IP 192.168.3.3.1982 > HOHNER.9100: tcp 0
        0x0000:  4500 0030 6b7d 4000 8006 07f3 c0a8 0303  E..0k}@.........
        0x0010:  c0a8 0304 07be 238c 7ebb 2438 0000 0000  ......#.~.$8....
        0x0020:  7002 ffff 2dee 0000 0204 0550 0101 0402  p...-......P....
IP 192.168.3.3.1983 > HOHNER.9100: tcp 0
        0x0000:  4500 0030 6b83 4000 8006 07ed c0a8 0303  E..0k.@.........
        0x0010:  c0a8 0304 07bf 238c 3334 eff4 0000 0000  ......#.34......
        0x0020:  7002 ffff adb7 0000 0204 0550 0101 0402  p..........P....

It keeps repeating this and the print queue on source machine never clears. It looks like the source is expecting a response from dest.

Any ideas how to spoof a response from the "printer"?
Am I mad?

What protocol did you select when creating the TCP port? Windows auto-chooses for some port numbers I think, and might have forced it to something other than raw.

That might be my problem. Maybe WinDump is catching the incoming traffic but there is no application/service listening so the port isn't open and the source isn't getting a response. Have I got that right?

Hmm, so how do I open a port for listening?

Maybye. Haven't used that tool.

It's already open, but nothing's there to listen. try netcat.

I would start by creating a PCL printer that prints to disk, then examine the disk file created to see if there is anything useful in it. I don't think you will find anything like a text file with one or two escape sequences at the beginning of it. You may be better off if you can create a generic/text only printer.

I already linked to a pcl2text utility.