OSDN Git Service

MOD: enum is researved word. It was changed to mailList.
[mdc/BetaProject.git] / src / org / jent / checksmtp / SocketProxy.java
1 package org.jent.checksmtp;
2
3 import java.io.IOException;
4 import java.io.InputStream;
5 import java.io.OutputStream;
6
7
8 /**
9  * Socket data proxy
10  */
11 public class SocketProxy implements Runnable {
12     InputStream is;
13     OutputStream os;
14     int mode = 0;
15
16     public SocketProxy(InputStream is, OutputStream os, int mode) {
17         this.is = is;
18         this.os = os;
19         this.mode = mode;
20     }
21
22     public void run() {
23         System.err.println("Start SocketProxy mode=" + mode + ":" + this);
24
25         int ch;
26
27         try {
28             while ((ch = is.read()) > 0) {
29                 os.write(ch);
30                 System.out.write(ch);
31             }
32         } catch (IOException e) {
33             System.err.println("Exception occured in SocketProxy mode=" + mode);
34             e.printStackTrace();
35         }
36
37         System.err.println("End  SocketProxy mode=" + mode + ":" + this);
38     }
39 }