1 package org.apache.axis2.transport.mail.server; 2 3 import org.apache.axis2.context.ConfigurationContext; 4 5 import java.io.IOException ; 6 import java.net.ServerSocket ; 7 import java.net.Socket ; 8 9 10 14 15 public class SMTPServer extends Thread { 16 private Storage st; 17 private ConfigurationContext configurationContext; 18 private int port; 19 public SMTPServer(Storage st,ConfigurationContext configurationContext,int port){ 20 this.st = st; 21 this.configurationContext =configurationContext; 22 this.port = port; 23 } 24 public void run(){ 25 runServer(); 26 } 27 28 public void runServer() { 29 ServerSocket ss = null; 30 try { 31 ss = new ServerSocket (port); 32 System.out.println("SMTP Server started on port " + port); 33 } catch (IOException ex) { 34 ex.printStackTrace(); 35 } 36 37 while (true) { 38 try { 39 Socket socket = ss.accept(); 41 42 SMTPWorker thread = new SMTPWorker(socket, st,configurationContext); 43 thread.start(); 44 45 } catch (IOException ex) { 46 ex.printStackTrace(); 47 } 48 } 49 } 50 51 } | Popular Tags |