View Javadoc

1   //$Id: HylaFAXPooledClient.java,v 1.8 2007/05/07 18:26:55 sjardine Exp $
2   //
3   //Copyright 2005 Steven Jardine <steve@mjnservices.com>
4   //Copyright 2005 MJN Services, Inc - http://www.mjnservices.com
5   //
6   //for information on the HylaFAX FAX server see
7   //http://www.hylafax.org/
8   //
9   //This library is free software; you can redistribute it and/or
10  //modify it under the terms of the GNU Library General Public
11  //License as published by the Free Software Foundation; either
12  //version 2 of the License, or (at your option) any later version.
13  //
14  //This library is distributed in the hope that it will be useful,
15  //but WITHOUT ANY WARRANTY; without even the implied warranty of
16  //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  //Library General Public License for more details.
18  //
19  //You should have received a copy of the GNU Library General Public
20  //License along with this library; if not, write to the Free
21  //Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  //
23  package gnu.hylafax.pool;
24  
25  import gnu.hylafax.HylaFAXClient;
26  import gnu.hylafax.Job;
27  import gnu.inet.ftp.ServerResponseException;
28  
29  import java.io.FileNotFoundException;
30  import java.io.IOException;
31  import java.io.InputStream;
32  import java.io.OutputStream;
33  import java.net.InetAddress;
34  import java.net.SocketException;
35  import java.net.UnknownHostException;
36  import java.util.Vector;
37  
38  import org.apache.commons.logging.Log;
39  import org.apache.commons.logging.LogFactory;
40  
41  /***
42   * This is an extension of the <code>gnu.hylafax.HylaFAXClient</code>
43   * specifically designed to work with the
44   * <code>gnu.hylafax.pool.ClientPool</code> pooling functionality.
45   * 
46   * @author <a href="mailto:sjardine@users.sourceforge.net">Steven Jardine </a>
47   */
48  public class HylaFAXPooledClient extends HylaFAXClient implements PooledClient,
49  	Runnable {
50  
51      private final static Log log = LogFactory.getLog(HylaFAXPooledClient.class);
52  
53      private ClientPool clientPool;
54  
55      private boolean terminated = false;
56  
57      private Thread thread = new Thread(this);
58  
59      private boolean valid = true;
60  
61      private boolean working = false;
62  
63      /***
64       * Default constructor.
65       * 
66       * @param clientPool
67       */
68      public HylaFAXPooledClient(ClientPool clientPool) {
69  	this.clientPool = clientPool;
70      }
71  
72      /*
73       * (non-Javadoc)
74       * 
75       * @see gnu.hylafax.ClientProtocol#admin(java.lang.String)
76       */
77      public void admin(String password) throws IOException,
78  	    ServerResponseException {
79  	log.warn("Method ignored for pooled clients.");
80      }
81  
82      /*
83       * (non-Javadoc)
84       * 
85       * @see gnu.hylafax.Client#createJob()
86       */
87      public Job createJob() throws ServerResponseException, IOException {
88  	if (valid && working)
89  	    return super.createJob();
90  	return null;
91      }
92  
93      /*
94       * (non-Javadoc)
95       * 
96       * @see gnu.hylafax.Client#delete(gnu.hylafax.Job)
97       */
98      public void delete(Job job) throws ServerResponseException, IOException {
99  	if (valid && working)
100 	    super.delete(job);
101     }
102 
103     private boolean forceReopen = false;
104 
105     /*
106      * (non-Javadoc)
107      * 
108      * @see gnu.hylafax.pool.PooledClient#destroy()
109      */
110     public void destroy() throws ClientPoolException {
111 	try {
112 	    super.quit();
113 	    stop();
114 	} catch (Exception e) {
115 	    throw new ClientPoolException(e.getMessage());
116 	}
117     }
118 
119     /*
120      * (non-Javadoc)
121      * 
122      * @see gnu.hylafax.ClientProtocol#filefmt()
123      */
124     public String filefmt() throws IOException, ServerResponseException {
125 	if (valid && working)
126 	    return super.filefmt();
127 	return null;
128     }
129 
130     /*
131      * (non-Javadoc)
132      * 
133      * @see gnu.hylafax.ClientProtocol#filefmt(java.lang.String)
134      */
135     public void filefmt(String value) throws IOException,
136 	    ServerResponseException {
137 	if (valid && working)
138 	    super.filefmt(value);
139     }
140 
141     /*
142      * (non-Javadoc)
143      * 
144      * @see gnu.hylafax.Client#get(java.lang.String, java.io.OutputStream)
145      */
146     public void get(String path, OutputStream out) throws IOException,
147 	    FileNotFoundException, ServerResponseException {
148 	if (valid && working)
149 	    super.get(path, out);
150     }
151 
152     /*
153      * (non-Javadoc)
154      * 
155      * @see gnu.hylafax.Client#getJob(long)
156      */
157     public Job getJob(long id) throws ServerResponseException, IOException {
158 	if (valid && working)
159 	    return super.getJob(id);
160 	return null;
161     }
162 
163     /*
164      * (non-Javadoc)
165      * 
166      * @see gnu.hylafax.Client#getList()
167      */
168     public Vector getList() throws IOException, FileNotFoundException,
169 	    ServerResponseException {
170 	if (valid && working)
171 	    return super.getList();
172 	return null;
173     }
174 
175     /*
176      * (non-Javadoc)
177      * 
178      * @see gnu.hylafax.Client#getList(java.lang.String)
179      */
180     public Vector getList(String path) throws IOException,
181 	    FileNotFoundException, ServerResponseException {
182 	if (valid && working)
183 	    return super.getList(path);
184 	return null;
185     }
186 
187     /*
188      * (non-Javadoc)
189      * 
190      * @see gnu.hylafax.Client#getNameList()
191      */
192     public Vector getNameList() throws IOException, ServerResponseException,
193 	    FileNotFoundException {
194 	if (valid && working)
195 	    return super.getNameList();
196 	return null;
197     }
198 
199     /*
200      * (non-Javadoc)
201      * 
202      * @see gnu.hylafax.Client#getNameList(java.lang.String)
203      */
204     public Vector getNameList(String path) throws IOException,
205 	    ServerResponseException, FileNotFoundException {
206 	if (valid && working)
207 	    return super.getNameList(path);
208 	return null;
209     }
210 
211     /*
212      * (non-Javadoc)
213      * 
214      * @see gnu.hylafax.Client#getPassive()
215      */
216     public boolean getPassive() {
217 	if (valid && working)
218 	    return super.getPassive();
219 	return false;
220     }
221 
222     /*
223      * (non-Javadoc)
224      * 
225      * @see gnu.inet.ftp.FtpClientProtocol#idle()
226      */
227     public long idle() throws IOException, ServerResponseException {
228 	if (valid && working)
229 	    return super.idle();
230 	return -1;
231     }
232 
233     /*
234      * (non-Javadoc)
235      * 
236      * @see gnu.inet.ftp.FtpClientProtocol#idle(long)
237      */
238     public void idle(long timeout) throws IOException, ServerResponseException {
239 	if (valid && working)
240 	    super.idle(timeout);
241     }
242 
243     /*
244      * (non-Javadoc)
245      * 
246      * @see gnu.hylafax.Client#interrupt(gnu.hylafax.Job)
247      */
248     public void interrupt(Job job) throws ServerResponseException, IOException {
249 	if (valid && working)
250 	    super.interrupt(job);
251     }
252 
253     /*
254      * (non-Javadoc)
255      * 
256      * @see gnu.hylafax.pool.PooledClient#isValid()
257      */
258     public boolean isValid() {
259 	return valid;
260     }
261 
262     /***
263      * @return true if the client is given out for work.
264      */
265     public boolean isWorking() {
266 	return working;
267     }
268 
269     /*
270      * (non-Javadoc)
271      * 
272      * @see gnu.hylafax.ClientProtocol#jdele(long)
273      */
274     public void jdele(long jobid) throws IOException, ServerResponseException {
275 	if (valid && working)
276 	    super.jdele(jobid);
277     }
278 
279     /*
280      * (non-Javadoc)
281      * 
282      * @see gnu.hylafax.ClientProtocol#jintr(long)
283      */
284     public void jintr(long jobid) throws IOException, ServerResponseException {
285 	if (valid && working)
286 	    super.jintr(jobid);
287     }
288 
289     /*
290      * (non-Javadoc)
291      * 
292      * @see gnu.hylafax.ClientProtocol#jkill(long)
293      */
294     public void jkill(long jobid) throws IOException, ServerResponseException {
295 	if (valid && working)
296 	    super.jkill(jobid);
297     }
298 
299     /*
300      * (non-Javadoc)
301      * 
302      * @see gnu.hylafax.ClientProtocol#jnew()
303      */
304     public void jnew() throws IOException, ServerResponseException {
305 	if (valid && working)
306 	    super.jnew();
307     }
308 
309     /*
310      * (non-Javadoc)
311      * 
312      * @see gnu.hylafax.ClientProtocol#job()
313      */
314     public long job() throws IOException, ServerResponseException {
315 	if (valid && working)
316 	    return super.job();
317 	return -1;
318     }
319 
320     /*
321      * (non-Javadoc)
322      * 
323      * @see gnu.hylafax.ClientProtocol#job(long)
324      */
325     public void job(long value) throws IOException, ServerResponseException {
326 	if (valid && working)
327 	    super.job(value);
328     }
329 
330     /*
331      * (non-Javadoc)
332      * 
333      * @see gnu.hylafax.ClientProtocol#jobfmt()
334      */
335     public String jobfmt() throws IOException, ServerResponseException {
336 	if (valid && working)
337 	    return super.jobfmt();
338 	return null;
339     }
340 
341     /*
342      * (non-Javadoc)
343      * 
344      * @see gnu.hylafax.ClientProtocol#jobfmt(java.lang.String)
345      */
346     public void jobfmt(String value) throws IOException,
347 	    ServerResponseException {
348 	if (valid && working)
349 	    super.jobfmt(value);
350     }
351 
352     /*
353      * (non-Javadoc)
354      * 
355      * @see gnu.hylafax.ClientProtocol#jparm(java.lang.String)
356      */
357     public String jparm(String parm) throws IOException,
358 	    ServerResponseException {
359 	if (valid && working)
360 	    return super.jparm(parm);
361 	return null;
362     }
363 
364     /*
365      * (non-Javadoc)
366      * 
367      * @see gnu.hylafax.ClientProtocol#jparm(java.lang.String, int)
368      */
369     public void jparm(String parm, int value) throws IOException,
370 	    ServerResponseException {
371 	if (valid && working)
372 	    super.jparm(parm, value);
373     }
374 
375     /*
376      * (non-Javadoc)
377      * 
378      * @see gnu.hylafax.ClientProtocol#jparm(java.lang.String, long)
379      */
380     public void jparm(String parm, long value) throws IOException,
381 	    ServerResponseException {
382 	if (valid && working)
383 	    super.jparm(parm, value);
384     }
385 
386     /*
387      * (non-Javadoc)
388      * 
389      * @see gnu.hylafax.ClientProtocol#jparm(java.lang.String, java.lang.Object)
390      */
391     public void jparm(String parm, Object value) throws IOException,
392 	    ServerResponseException {
393 	if (valid && working)
394 	    super.jparm(parm, value);
395     }
396 
397     /*
398      * (non-Javadoc)
399      * 
400      * @see gnu.hylafax.ClientProtocol#jparm(java.lang.String, java.lang.String)
401      */
402     public void jparm(String parm, String value) throws IOException,
403 	    ServerResponseException {
404 	if (valid && working)
405 	    super.jparm(parm, value);
406     }
407 
408     /*
409      * (non-Javadoc)
410      * 
411      * @see gnu.hylafax.ClientProtocol#jrest()
412      */
413     public void jrest() throws IOException, ServerResponseException {
414 	if (valid && working)
415 	    super.jrest();
416     }
417 
418     /*
419      * (non-Javadoc)
420      * 
421      * @see gnu.hylafax.ClientProtocol#jsubm()
422      */
423     public long jsubm() throws IOException, ServerResponseException {
424 	if (valid && working)
425 	    return super.jsubm();
426 	return -1;
427     }
428 
429     /*
430      * (non-Javadoc)
431      * 
432      * @see gnu.hylafax.ClientProtocol#jsubm(long)
433      */
434     public int jsubm(long jobid) throws IOException, ServerResponseException {
435 	if (valid && working)
436 	    return super.jsubm(jobid);
437 	return -1;
438     }
439 
440     /*
441      * (non-Javadoc)
442      * 
443      * @see gnu.hylafax.ClientProtocol#jsusp(long)
444      */
445     public void jsusp(long jobid) throws IOException, ServerResponseException {
446 	if (valid && working)
447 	    super.jsusp(jobid);
448     }
449 
450     /*
451      * (non-Javadoc)
452      * 
453      * @see gnu.hylafax.ClientProtocol#jwait(long)
454      */
455     public void jwait(long jobid) throws IOException, ServerResponseException {
456 	if (valid && working)
457 	    super.jwait(jobid);
458     }
459 
460     /*
461      * (non-Javadoc)
462      * 
463      * @see gnu.hylafax.Client#kill(gnu.hylafax.Job)
464      */
465     public void kill(Job job) throws ServerResponseException, IOException {
466 	if (valid && working)
467 	    super.kill(job);
468     }
469 
470     /*
471      * (non-Javadoc)
472      * 
473      * @see gnu.hylafax.ClientProtocol#mdmfmt()
474      */
475     public String mdmfmt() throws IOException, ServerResponseException {
476 	if (valid && working)
477 	    return super.mdmfmt();
478 	return null;
479     }
480 
481     /*
482      * (non-Javadoc)
483      * 
484      * @see gnu.hylafax.ClientProtocol#mdmfmt(java.lang.String)
485      */
486     public void mdmfmt(String value) throws IOException,
487 	    ServerResponseException {
488 	if (valid && working)
489 	    super.mdmfmt(value);
490     }
491 
492     /*
493      * (non-Javadoc)
494      * 
495      * @see gnu.inet.ftp.FtpClientProtocol#mode(char)
496      */
497     public void mode(char mode) throws IOException, ServerResponseException {
498 	if (valid && working)
499 	    super.mode(mode);
500     }
501 
502     /*
503      * (non-Javadoc)
504      * 
505      * @see gnu.inet.ftp.FtpClientProtocol#noop()
506      */
507     public void noop() throws IOException, ServerResponseException {
508 	if (valid && working)
509 	    super.noop();
510     }
511 
512     /*
513      * (non-Javadoc)
514      * 
515      * @see gnu.inet.ftp.FtpClientProtocol#open()
516      */
517     public void open() throws UnknownHostException, IOException,
518 	    ServerResponseException {
519 	log.warn("Method open() ignored for pooled clients.");
520     }
521 
522     /*
523      * (non-Javadoc)
524      * 
525      * @see gnu.inet.ftp.FtpClientProtocol#open(java.lang.String)
526      */
527     public void open(String host) throws UnknownHostException, IOException,
528 	    ServerResponseException {
529 	log.warn("Method open(String host) ignored for pooled clients.");
530     }
531 
532     /*
533      * (non-Javadoc)
534      * 
535      * @see gnu.inet.ftp.FtpClientProtocol#open(java.lang.String, int)
536      */
537     public void open(String host, int newPort) throws UnknownHostException,
538 	    IOException, ServerResponseException {
539 	log.warn("Method open(String host, int port)"
540 		+ " ignored for pooled clients.");
541     }
542 
543     /*
544      * (non-Javadoc)
545      * 
546      * @see gnu.inet.ftp.FtpClientProtocol#pass(java.lang.String)
547      */
548     public void pass(String password) throws IOException,
549 	    ServerResponseException {
550 	log.warn("Method pass(String password) ignored for pooled clients.");
551     }
552 
553     /***
554      * Set the admin password for pooled clients.
555      * 
556      * @param password
557      * @throws IOException
558      * @throws ServerResponseException
559      */
560     void poolAdmin(String password) throws IOException, ServerResponseException {
561 	super.admin(password);
562     }
563 
564     /***
565      * Open method for pooled clients.
566      * 
567      * @throws UnknownHostException
568      * @throws IOException
569      * @throws ServerResponseException
570      */
571     void poolOpen() throws UnknownHostException, IOException,
572 	    ServerResponseException {
573 	super.open();
574     }
575 
576     /***
577      * Open method for pooled clients.
578      * 
579      * @param host
580      * @throws UnknownHostException
581      * @throws IOException
582      * @throws ServerResponseException
583      */
584     void poolOpen(String host) throws UnknownHostException, IOException,
585 	    ServerResponseException {
586 	super.open(host, DEFAULT_PORT);
587     }
588 
589     /***
590      * Open method for pooled clients.
591      * 
592      * @param host
593      * @param port
594      * @throws UnknownHostException
595      * @throws IOException
596      * @throws ServerResponseException
597      */
598     void poolOpen(String host, int newPort) throws UnknownHostException,
599 	    IOException, ServerResponseException {
600 	super.open(host, newPort);
601     }
602 
603     /***
604      * Password method for pooled clients.
605      * 
606      * @param password
607      * @throws IOException
608      * @throws ServerResponseException
609      */
610     void poolPass(String password) throws IOException, ServerResponseException {
611 	super.pass(password);
612     }
613 
614     /***
615      * Timezone method for pooled clients.
616      * 
617      * @param value
618      * @throws IOException
619      * @throws ServerResponseException
620      */
621     void poolTzone(String value) throws IOException, ServerResponseException {
622 	super.tzone(value);
623     }
624 
625     /***
626      * User method for pooled clients.
627      * 
628      * @param username
629      * @return the user associated with the username.
630      * @throws IOException
631      * @throws ServerResponseException
632      */
633     boolean poolUser(String username) throws IOException,
634 	    ServerResponseException {
635 	return super.user(username);
636     }
637 
638     /*
639      * (non-Javadoc)
640      * 
641      * @see gnu.hylafax.Client#put(java.io.InputStream)
642      */
643     public String put(InputStream in) throws IOException,
644 	    ServerResponseException {
645 	if (valid && working)
646 	    return super.put(in);
647 	return null;
648     }
649 
650     /*
651      * (non-Javadoc)
652      * 
653      * @see gnu.hylafax.Client#put(java.io.InputStream, java.lang.String)
654      */
655     public void put(InputStream in, String pathname) throws IOException,
656 	    ServerResponseException {
657 	if (valid && working)
658 	    super.put(in, pathname);
659     }
660 
661     /*
662      * (non-Javadoc)
663      * 
664      * @see gnu.hylafax.Client#putTemporary(java.io.InputStream)
665      */
666     public String putTemporary(InputStream data) throws IOException,
667 	    ServerResponseException {
668 	if (valid && working)
669 	    return super.putTemporary(data);
670 	return null;
671     }
672 
673     /*
674      * (non-Javadoc)
675      * 
676      * @see gnu.inet.ftp.FtpClientProtocol#quit()
677      */
678     public void quit() throws IOException, ServerResponseException {
679 	try {
680 	    clientPool.put(this);
681 	} catch (ClientPoolException e) {
682 	    log.error(e);
683 	}
684     }
685 
686     /*
687      * (non-Javadoc)
688      * 
689      * @see gnu.hylafax.ClientProtocol#rcvfmt()
690      */
691     public String rcvfmt() throws IOException, ServerResponseException {
692 	if (valid && working)
693 	    return super.rcvfmt();
694 	return null;
695     }
696 
697     /*
698      * (non-Javadoc)
699      * 
700      * @see gnu.hylafax.ClientProtocol#rcvfmt(java.lang.String)
701      */
702     public void rcvfmt(String value) throws IOException,
703 	    ServerResponseException {
704 	if (valid && working)
705 	    super.rcvfmt(value);
706     }
707 
708     /***
709      * Attempts to reopen the client connection.
710      * 
711      * @throws ClientPoolException
712      */
713     private void reopen() throws ClientPoolException {
714 	try {
715 	    log.debug("Attempting to reopen client.");
716 
717 	    forceReopen = false;
718 	    try {
719 		super.quit();
720 	    } catch (SocketException e) {
721 		// Don't care.
722 	    }
723 	    stop();
724 	    clientPool.openClient(this);
725 
726 	    log.debug("Reopen successful.");
727 	} catch (Exception e) {
728 	    throw new ClientPoolException(e.getMessage());
729 	}
730     }
731 
732     private long lastNoop = -1;
733 
734     private long lastReopen = -1;
735 
736     /*
737      * (non-Javadoc)
738      * 
739      * @see java.lang.Runnable#run()
740      */
741     public void run() {
742 	Thread.currentThread().setName("Pooled Client");
743 	while (!terminated) {
744 	    try {
745 		// Only send noop on idle connections every 10 seconds.
746 		if (!working) {
747 		    long time = System.currentTimeMillis();
748 		    if (forceReopen
749 			    || (time - lastReopen) >= clientPool
750 				    .getConfiguration().getMaxIdleTime()) {
751 			reopen();
752 			lastReopen = System.currentTimeMillis();
753 		    } else if ((time - lastNoop) >= clientPool
754 			    .getConfiguration().getMaxNoopTime()) {
755 			super.noop();
756 			lastNoop = System.currentTimeMillis();
757 		    }
758 		}
759 
760 		Thread.sleep(1000);
761 		if (clientPool.isStopped())
762 		    terminated = true;
763 	    } catch (InterruptedException e) {
764 		// Do nothing.
765 	    } catch (Exception e) {
766 		log.debug(e.getMessage(), e);
767 		// All other exceptions should initiate a reopen of the client.
768 		valid = false;
769 		forceReopen = true;
770 		// Try and reopen the connection.
771 		try {
772 		    Thread.sleep(5000); // Wait before attempting to reopen
773 		    // connection.
774 		} catch (Exception e2) {
775 		    // Do Nothing.
776 		}
777 	    }
778 	}
779     }
780 
781     /*
782      * (non-Javadoc)
783      * 
784      * @see gnu.hylafax.Client#setPassive(boolean)
785      */
786     public void setPassive(boolean passive) {
787 	if (valid && working)
788 	    super.setPassive(passive);
789     }
790 
791     /*
792      * (non-Javadoc)
793      * 
794      * @see gnu.hylafax.pool.PooledClient#setValid(boolean)
795      */
796     public void setValid(boolean valid) {
797 	this.valid = valid;
798     }
799 
800     /***
801      * Set to true when the client has been given out of the pool. false when
802      * the client is idle.
803      * 
804      * @param working
805      */
806     void setWorking(boolean working) {
807 	this.working = working;
808     }
809 
810     /*
811      * (non-Javadoc)
812      * 
813      * @see gnu.inet.ftp.FtpClientProtocol#size(java.lang.String)
814      */
815     public long size(String pathname) throws IOException,
816 	    FileNotFoundException, ServerResponseException {
817 	if (valid && working)
818 	    return super.size(pathname);
819 	return -1;
820 
821     }
822 
823     /***
824      * Start the maintaince thread for this client.
825      */
826     public void start() {
827 	if (thread.isAlive())
828 	    return;
829 
830 	terminated = false;
831 	lastNoop = lastReopen = System.currentTimeMillis();
832 	thread.start();
833     }
834 
835     /***
836      * Stops the maintaince thread for this client.
837      */
838     public void stop() {
839 	log.debug("stopping client thread");
840 	terminated = true;
841     }
842 
843     /*
844      * (non-Javadoc)
845      * 
846      * @see gnu.inet.ftp.FtpClientProtocol#stot(java.io.InputStream)
847      */
848     public String stot(InputStream data) throws IOException,
849 	    ServerResponseException {
850 	if (valid && working)
851 	    return super.stot(data);
852 	return null;
853     }
854 
855     /*
856      * (non-Javadoc)
857      * 
858      * @see gnu.hylafax.Client#submit(gnu.hylafax.Job)
859      */
860     public void submit(Job job) throws ServerResponseException, IOException {
861 	if (valid && working)
862 	    super.submit(job);
863     }
864 
865     /*
866      * (non-Javadoc)
867      * 
868      * @see gnu.hylafax.Client#suspend(gnu.hylafax.Job)
869      */
870     public void suspend(Job job) throws ServerResponseException, IOException {
871 	if (valid && working)
872 	    super.suspend(job);
873     }
874 
875     /*
876      * (non-Javadoc)
877      * 
878      * @see gnu.hylafax.ClientProtocol#tzone(java.lang.String)
879      */
880     public void tzone(String value) throws IOException, ServerResponseException {
881 	log.warn("Method tzone(String value) ignored for pooled clients.");
882     }
883 
884     /*
885      * (non-Javadoc)
886      * 
887      * @see gnu.inet.ftp.FtpClientProtocol#user(java.lang.String)
888      */
889     public boolean user(String username) throws IOException,
890 	    ServerResponseException {
891 	log.warn("Method user(String username) ignored for pooled clients.");
892 	return false;
893     }
894 
895     /*
896      * (non-Javadoc)
897      * 
898      * @see gnu.hylafax.ClientProtocol#vrfy(java.lang.String)
899      */
900     public InetAddress vrfy(String dialstring) throws IOException,
901 	    ServerResponseException {
902 	if (valid && working)
903 	    return super.vrfy(dialstring);
904 	return null;
905     }
906 
907     /*
908      * (non-Javadoc)s
909      * 
910      * @see gnu.hylafax.Client#wait(gnu.hylafax.Job)
911      */
912     public void wait(Job job) throws ServerResponseException, IOException {
913 	if (valid && working)
914 	    super.wait(job);
915     }
916 
917 }