static final int HELO=1; static final int MAIL=2; static final int RCPT=3; static final int DATA=4; static final int END_DATA=5; static final int OUIT=6; static final int FINISHED=9; NVTOutputStream out; NVTInputStream in; String hostName; public SMTPServer( )
super( );
public void run( ) try ServerSOcket server= (1) ;//在1145号端口建立下CP服务器插口 int localPort=server. getLocalPort( );//监听连接端口 hostNama= (2) ;//获取本地主机域名 SVstem. out. prfntln("listening on port"+locaIPort+"."); boolean finished=false; do Socket client= (3) ;//监听等待,直到建立连接,返回对象client Stnng destName= (4) ;//获得所连接的客户主机IP地址的域名 int destPort=client. getPort( );//所连接的客户主机端口号 System. out pnntln("Accepted connection to"+destNama+"on port"+destPort+"." //控制台显示连接 out=new NVT0utputStream(client. get OutputStream( )); In=new NVTInputStream( (5) );//建立与连接关联的输入流 (6) ;//接收邮件 (7) ;//关闭连接对象 while(! finished); catch(UnknownHostException ex) SVstem.out.printtn("UnknownHostException occurred.");//出错处理 cath(lOException ex) System. out. println("lOException occurred.");