What is port 9100 & How to print to it

Of the many methods for printing the simplest and most genius is port 9100. At the very basic printing over port 9100 requires you to open a TCP connection to the printer’s port 9100, push some text, then close the connection.

For a presentation at Microsoft I wanted to end on a fun note and provide some printing trivia. My online searches for information related to port 9100 and printing through said port turned up sparse. The only reason I knew anything about port 9100 was from pouring over Foomatic’s driver metadata database two summers ago. I think this method might also be known as JetDirect or Direct Print. WIkipedia’s only obvious mention is the port’s official registration as “PDL Data Stream”.

As the official port registration implies that text I mentioned pushing to the printer can in fact have PDL instructions embed.

PDL stands for Page Description Language. This term is related to PCL which stands for Printer Command Language. PCL is not supposed to be a PDL since it allows for printer control. In theory this extra power should make PCL a member of the more general Printer Control Language group. Thus, in theory, when Wikipedia says “PDL Data Stream” the implication is that there is no control granted over the printer itself. In practice printers sometimes treat the PDL sent over port 9100 as commands. I think some HP printer firmware updates get sent this way. The net result has been various security bugs over the years.

The genius of port 9100 is in the pure reality that no other network printing protocol can be simpler. Even printing over UDP would complicate the process by requiring a END_OF_PRINT_JOB instruction. Instead port 9100 treats the TCP’s closure as the submit command.

You can try printing over port 9100 yourself by running from the command line:

$ netcat PRINTER_IP 9100
$ Hello World
$ <Ctrl+c>

Hope that helped. I also hope I did not write anything too inaccurate.

6 thoughts on “What is port 9100 & How to print to it

    1. danieru Post author

      Printing anything but 7bit ASCI would require using the printer’s Page Description Language which is much more complex. If you need something that complex for a program you are writing you may want to look into CUPS or libcups combined with linux’s filter chain.

      Reply
      1. Ye olde printer

        You open a connection to port 9100 then use the printer job language “PJL” commands to force the start of a new job (in case the port was left in a bad state) set up the print parameters such as input tray output finishing options, resolution and the like then use the @PJL ENTER_LANGUAGE command to enter whatever printer language is supported by the printer and whatever format you wish to generate. PJL manuals can be found online. Note in the example below the comments preceded by “#” are not legal PJL and are intended merely to be informative. The sequence is:
        ^[%-12345X@PJL JOB # This string exits any existing job and starts a new one ^[ is escape (0x1b)
        @PJL SET RESOLUTION = 300 # White space does not matter capitalization does
        @PJL SET COPIES = 4 # Set copy count to four
        @PJL ENTER LANGUAGE = POSTSCRIPT # What follows is PostScript NOT PJL
        %!PS
        .5 setgray
        clippath pathbbox moveto lineto stroke showpage
        ^D
        @PJL EOJ #cleanly exit the PostScript Job and prepare for a new one.

        Reply
  1. rhfjr

    I am a novice with computer work a rounds.

    I have Win 8.1 and trying to connect via WiFi from an Epson WF3540 printer all in one. I can connect to the computer with the Firewall turned off. However when the Firewall is turned on no connection.

    Will the following open port 9100 work when the the Firewall is turned on?

    $ netcat PRINTER_IP 9100
    $ Hello World
    $

    according to your article, What is port 9100 & How to print to it.

    I have three ports to choose from according to Epson, 9100, 2958, and 3629.
    My cable company wants a 10 month service agreement to turn one of the three ports on.

    How does one remove that code if it does not work?

    Respectfully,

    Reply
    1. danieru Post author

      Why are you trying to connect from the Printer to the Computer? As well you should not turn on those ports at your cable internet service provider. That would expose your printer to the world and allow anyone to print on it.

      Sorry I’m honestly not sure what you are trying to do.

      Reply
  2. ar

    Is there a way to get some job status or printer status via 9100? Newer HP Printers simply power off after some time and even network gets stopped so it is impossible to wake these remotely.

    So I’m trying to run periodic job (every few minutes) that does some query to the printer to prevent it from going into sleep and power off.

    Ideas welcome.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *