LPD - receive data has always same length
<p>I am writing virtual printer using <a href="https://sourceforge.net/projects/lpdspooler/" rel="nofollow">this</a> existing solution. I have problem with the receive data subcommand.</p>

<pre><code>+----+-------+----+------+----+
| 03 | Count | SP | Name | LF |
+----+-------+----+------+----+
Command code - 3
Operand 1 - Number of bytes in data file
Operand 2 - Name of data file
</code></pre>

<p>Whenever I process this command, the data file size - Count - is always some weird big number - 125899906843000. I am stuck here and I cant find out why this happens. Does somebody know where should be a problem? Thanks</p>

<hr>

<p>EDIT:</p>

<p>I've find where the problem is. <a href="https://www.brooksnet.com/content/faq-why-lpr-byte-counting-enabled-required" rel="nofollow">Here</a> is the answer for my own question. The problem is because Microsoft sends an impossibly huge number, instead of the actual size of the file in bytes. There are two ways to solve the problem:</p>

<ol>
<li>Edit TCP/IP port of the virtual printer and enable LRP byte counting. This forces Windows to count the number of bytes in the file and send this value in the Receive data file subcommand.</li>
<li>Modify RPM so that it handles the "unknown length file" situation by receiving all data from the request to send the data file until the connection is closed by the LPR client.</li>
</ol>