KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > transport > mail > server > POP3Server


1 package org.apache.axis2.transport.mail.server;
2
3 import java.io.IOException JavaDoc;
4 import java.net.ServerSocket JavaDoc;
5 import java.net.Socket JavaDoc;
6
7 import org.apache.axis2.engine.AxisFault;
8 import org.apache.commons.logging.Log;
9 import org.apache.commons.logging.LogFactory;
10 /**
11  * @author Chamil Thanthrimudalige
12  */

13
14 public class POP3Server extends Thread JavaDoc {
15     protected static Log log = LogFactory.getLog(POP3Server.class.getName());
16     private ServerSocket JavaDoc serverSocket;
17     private Storage st = null;
18
19     
20     public POP3Server(Storage st,int port) throws AxisFault {
21         this.st = st;
22         try {
23             serverSocket = new ServerSocket JavaDoc(port);
24             System.out.println("Server started on port " + port);
25         } catch(IOException JavaDoc e) {
26             throw new AxisFault(e);
27         }
28     }
29
30     public void run() {
31         while(true) {
32             try {
33                 Socket JavaDoc socket = serverSocket.accept();
34                 POP3Worker thread = new POP3Worker(socket, st);
35                 thread.start();
36             } catch(Exception JavaDoc e) {
37                 log.error(e);
38             }
39         }
40     }
41 }
Popular Tags