<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
  <head>
    <meta name="generator" content="HTML Tidy, see www.w3.org">
    <title>Socket API</title>
    <meta name="GENERATOR" content=
    "Modular DocBook HTML Stylesheet Version 1.7">
    <link rel="HOME" title=" LPRng Reference Manual" href=
    "index.htm">
    <link rel="UP" title="Printer Communication and Protocols "
    href="printercomm.htm">
    <link rel="PREVIOUS" title="RFC1179 (LPD) Connection" href=
    "x4881.htm">
    <link rel="NEXT" title="AppSocket TCP/IP Protocol " href=
    "appsocket.htm">
  </head>

  <body class="SECT1" bgcolor="#FFFFFF" text="#000000" link=
  "#0000FF" vlink="#840084" alink="#0000FF">
    <div class="NAVHEADER">
      <table summary="Header navigation table" width="100%" border=
      "0" cellpadding="0" cellspacing="0">
        <tr>
          <th colspan="3" align="center">LPRng Reference Manual: 24
          Sep 2004 (For LPRng-3.8.28)</th>
        </tr>

        <tr>
          <td width="10%" align="left" valign="bottom"><a href=
          "x4881.htm" accesskey="P">Prev</a></td>

          <td width="80%" align="center" valign="bottom">Chapter
          11. Printer Communication and Protocols</td>

          <td width="10%" align="right" valign="bottom"><a href=
          "appsocket.htm" accesskey="N">Next</a></td>
        </tr>
      </table>
      <hr align="LEFT" width="100%">
    </div>

    <div class="SECT1">
      <h1 class="SECT1"><a name="SOCKETAPI">11.3. Socket
      API</a></h1>

      <p>The Socket API is a very flexible job transfer protocol.
      It is widely support by most Print Server manufacturers, with
      the Hewlett Packard JetDirect setting the <span class=
      "emphasis"><i class="EMPHASIS">de facto</i></span> standard.
      The Socket API is extremely simple.</p>

      <ol type="1">
        <li>
          <p>The user establishes a connection to TCP/IP port on
          the Printer or Network Print spooler. The HP JetDirect
          uses port 9100 by default, but other ports are used as
          well. This connection may be refused if the printer is
          busy printing a job.</p>
        </li>

        <li>
          <p>When the network connection is established to a system
          which has an <span class="emphasis"><i class=
          "EMPHASIS">internal printer</i></span> or for which the
          Network Print Spooler is an integral part of the system,
          the printer usually flushes all internal buffers and
          readies itself to receive a new job. However, when you
          are using an external Print Server box, you may need to
          send specific initialization sequences to the printer to
          ensure that it is reset correctly and is ready to receive
          new jobs.</p>
        </li>

        <li>
          <p>When the connection is made, all bytes sent to the
          connection are either transferred to and external
          interface to directly to a <span class="emphasis"><i
          class="EMPHASIS">print buffer</i></span> used by the
          printer's Print Engine.</p>
        </li>

        <li>
          <p>The connection is bidirectional, and information sent
          to the external port by an external printer or error
          messages and status generated by the printer's Print
          Engine will be transferred over the data link to the
          user.</p>
        </li>

        <li>
          <p>The Network Print spooler will keep the connection
          open until it is closed by the user. During this period
          it may continue to report status or other information
          such as printer On Line, paper outages, and so forth.</p>
        </li>

        <li>
          <p>If the connection to the printer is <span class=
          "emphasis"><i class="EMPHASIS">half-closed</i></span>,
          that is, the <code class="FUNCTION">shutdown()</code>
          network system call is used to indicate to the remote
          printer that no further data will be sent, then the
          printer may immediately terminate the network connection.
          This means that no further network or status messages
          will be sent to the user.</p>
        </li>

        <li>
          <p>If the connection is to a External Print Server, then
          usually the connection can be immediately re-established.
          It is the responsibility of the user to ensure that a the
          printer has finished its work before sending a new
          job.</p>
        </li>

        <li>
          <p>If the connection is to an internal Print Server, then
          usually the printer will not allow the connection to be
          made, or will refuse all data transfers on the connection
          until the printer finishes with the previous job and all
          internal buffers have been cleared.</p>
        </li>
      </ol>
      <br>
      <br>

      <p>The following is a sample printcap showing how to use the
      Socket API:</p>

      <div class="INFORMALEXAMPLE">
        <a name="AEN4937"></a>
<pre class="SCREEN">
    lp:
      # make a socket connection to port 9100
      :lp=10.0.0.2%9100
</pre>
      </div>
      <br>
      <br>

      <p>You can use the <a href=
      "http://www.l0pht.com/~weld/netcat/" target="_top">netcat</a>
      utility by Hobbit <code class="EMAIL">&lt;<a href=
      "mailto:Hobbit@avian.org">Hobbit@avian.org</a>&gt;</code> to
      test that the Socket interface is available and working. If
      <tt class="FILENAME">ellipse.ps</tt> is a test file, then:
      The simplest and easiest way to print a file to a network
      printer appears</p>

      <div class="INFORMALEXAMPLE">
        <a name="AEN4943"></a>
<pre class="SCREEN">
      nc printer.ip.addr 9100 &lt; file
    Example:
      nc 10.0.0.25 9100 &lt; ellipse.ps
</pre>
      </div>
      <br>
      <br>
    </div>

    <div class="NAVFOOTER">
      <hr align="LEFT" width="100%">

      <table summary="Footer navigation table" width="100%" border=
      "0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="33%" align="left" valign="top"><a href=
          "x4881.htm" accesskey="P">Prev</a></td>

          <td width="34%" align="center" valign="top"><a href=
          "index.htm" accesskey="H">Home</a></td>

          <td width="33%" align="right" valign="top"><a href=
          "appsocket.htm" accesskey="N">Next</a></td>
        </tr>

        <tr>
          <td width="33%" align="left" valign="top">RFC1179 (LPD)
          Connection</td>

          <td width="34%" align="center" valign="top"><a href=
          "printercomm.htm" accesskey="U">Up</a></td>

          <td width="33%" align="right" valign="top">AppSocket
          TCP/IP Protocol</td>
        </tr>
      </table>
    </div>
  </body>
</html>



syntax highlighted by Code2HTML, v. 0.9.1