I want to monitor some network-printer status via java, maybe tcp/ip ....

Stephen Ostermiller

Most workgroup laser printers will give you status over several protocols. I only have java code for LPR, but you could also try HTTP (web pages) and SNMP (Simple network manegment protocol). SNMP is probably your best bet, but I don't have java code. Different printers give different information for LPR and have different formats for the web pages they serve. SNMP should be easier to get the information you need from a variety of printers.

Here's an example using the LPR mechanism to get the status:

 * Query the state of the print queue.
 * @param host Internet host name or IP address.
 * @param queue The name of the queue (traditionally the username).
 * @param out results of the request are written here.
 * @param shortResponse true if a short response is desired, false if a long response is desired.
 * @throws IOException if communication with the printer fails.
static void sendQueueState(String host, String queue, OutputStream out, boolean shortResponse) {
    Socket socket = new Socket(host, 515);
    OutputStream sout = socket.getOutputStream(); 
    sout.write(new byte[] {(byte)(shortResponse?3:4)});
    sout.write(" List

    InputStream sin = socket.getInputStream();
    byte[] cbuffer = new byte[1024];
    int read;
    while ((read = sin.read(cbuffer)) != -1){
	    out.write(cbuffer, 0, read);