1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2 3<html> 4 <head> 5 <meta name="generator" content="HTML Tidy, see www.w3.org"> 6 <title>Socket API</title> 7 <meta name="GENERATOR" content= 8 "Modular DocBook HTML Stylesheet Version 1.7"> 9 <link rel="HOME" title=" LPRng Reference Manual" href= 10 "index.htm"> 11 <link rel="UP" title="Printer Communication and Protocols " 12 href="printercomm.htm"> 13 <link rel="PREVIOUS" title="RFC1179 (LPD) Connection" href= 14 "x4867.htm"> 15 <link rel="NEXT" title="AppSocket TCP/IP Protocol " href= 16 "appsocket.htm"> 17 </head> 18 19 <body class="SECT1" bgcolor="#FFFFFF" text="#000000" link= 20 "#0000FF" vlink="#840084" alink="#0000FF"> 21 <div class="NAVHEADER"> 22 <table summary="Header navigation table" width="100%" border= 23 "0" cellpadding="0" cellspacing="0"> 24 <tr> 25 <th colspan="3" align="center">LPRng Reference Manual: 5 26 Sep 2003 (For LPRng-3.8.22)</th> 27 </tr> 28 29 <tr> 30 <td width="10%" align="left" valign="bottom"><a href= 31 "x4867.htm" accesskey="P">Prev</a></td> 32 33 <td width="80%" align="center" valign="bottom">Chapter 34 11. Printer Communication and Protocols</td> 35 36 <td width="10%" align="right" valign="bottom"><a href= 37 "appsocket.htm" accesskey="N">Next</a></td> 38 </tr> 39 </table> 40 <hr align="LEFT" width="100%"> 41 </div> 42 43 <div class="SECT1"> 44 <h1 class="SECT1"><a name="SOCKETAPI">11.3. Socket 45 API</a></h1> 46 47 <p>The Socket API is a very flexible job transfer protocol. 48 It is widely support by most Print Server manufacturers, with 49 the Hewlett Packard JetDirect setting the <span class= 50 "emphasis"><i class="EMPHASIS">de facto</i></span> standard. 51 The Socket API is extremely simple.</p> 52 53 <ol type="1"> 54 <li> 55 <p>The user establishes a connection to TCP/IP port on 56 the Printer or Network Print spooler. The HP JetDirect 57 uses port 9100 by default, but other ports are used as 58 well. This connection may be refused if the printer is 59 busy printing a job.</p> 60 </li> 61 62 <li> 63 <p>When the network connection is established to a system 64 which has an <span class="emphasis"><i class= 65 "EMPHASIS">internal printer</i></span> or for which the 66 Network Print Spooler is an integral part of the system, 67 the printer usually flushes all internal buffers and 68 readies itself to receive a new job. However, when you 69 are using an external Print Server box, you may need to 70 send specific initialization sequences to the printer to 71 ensure that it is reset correctly and is ready to receive 72 new jobs.</p> 73 </li> 74 75 <li> 76 <p>When the connection is made, all bytes sent to the 77 connection are either transferred to and external 78 interface to directly to a <span class="emphasis"><i 79 class="EMPHASIS">print buffer</i></span> used by the 80 printer's Print Engine.</p> 81 </li> 82 83 <li> 84 <p>The connection is bidirectional, and information sent 85 to the external port by an external printer or error 86 messages and status generated by the printer's Print 87 Engine will be transferred over the data link to the 88 user.</p> 89 </li> 90 91 <li> 92 <p>The Network Print spooler will keep the connection 93 open until it is closed by the user. During this period 94 it may continue to report status or other information 95 such as printer On Line, paper outages, and so forth.</p> 96 </li> 97 98 <li> 99 <p>If the connection to the printer is <span class= 100 "emphasis"><i class="EMPHASIS">half-closed</i></span>, 101 that is, the <code class="FUNCTION">shutdown()</code> 102 network system call is used to indicate to the remote 103 printer that no further data will be sent, then the 104 printer may immediately terminate the network connection. 105 This means that no further network or status messages 106 will be sent to the user.</p> 107 </li> 108 109 <li> 110 <p>If the connection is to a External Print Server, then 111 usually the connection can be immediately re-established. 112 It is the responsibility of the user to ensure that a the 113 printer has finished its work before sending a new 114 job.</p> 115 </li> 116 117 <li> 118 <p>If the connection is to an internal Print Server, then 119 usually the printer will not allow the connection to be 120 made, or will refuse all data transfers on the connection 121 until the printer finishes with the previous job and all 122 internal buffers have been cleared.</p> 123 </li> 124 </ol> 125 <br> 126 <br> 127 128 <p>The following is a sample printcap showing how to use the 129 Socket API:</p> 130 131 <div class="INFORMALEXAMPLE"> 132 <a name="AEN4923"></a> 133<pre class="SCREEN"> 134 lp: 135 # make a socket connection to port 9100 136 :lp=10.0.0.2%9100 137</pre> 138 </div> 139 <br> 140 <br> 141 142 <p>You can use the <a href= 143 "http://www.l0pht.com/~weld/netcat/" target="_top">netcat</a> 144 utility by Hobbit <code class="EMAIL"><<a href= 145 "mailto:Hobbit@avian.org">Hobbit@avian.org</a>></code> to 146 test that the Socket interface is available and working. If 147 <tt class="FILENAME">ellipse.ps</tt> is a test file, then: 148 The simplest and easiest way to print a file to a network 149 printer appears</p> 150 151 <div class="INFORMALEXAMPLE"> 152 <a name="AEN4929"></a> 153<pre class="SCREEN"> 154 nc printer.ip.addr 9100 < file 155 Example: 156 nc 10.0.0.25 9100 < ellipse.ps 157</pre> 158 </div> 159 <br> 160 <br> 161 </div> 162 163 <div class="NAVFOOTER"> 164 <hr align="LEFT" width="100%"> 165 166 <table summary="Footer navigation table" width="100%" border= 167 "0" cellpadding="0" cellspacing="0"> 168 <tr> 169 <td width="33%" align="left" valign="top"><a href= 170 "x4867.htm" accesskey="P">Prev</a></td> 171 172 <td width="34%" align="center" valign="top"><a href= 173 "index.htm" accesskey="H">Home</a></td> 174 175 <td width="33%" align="right" valign="top"><a href= 176 "appsocket.htm" accesskey="N">Next</a></td> 177 </tr> 178 179 <tr> 180 <td width="33%" align="left" valign="top">RFC1179 (LPD) 181 Connection</td> 182 183 <td width="34%" align="center" valign="top"><a href= 184 "printercomm.htm" accesskey="U">Up</a></td> 185 186 <td width="33%" align="right" valign="top">AppSocket 187 TCP/IP Protocol</td> 188 </tr> 189 </table> 190 </div> 191 </body> 192</html> 193 194