问题 多项选择题

1.SMTP是发送E-mail的协议,常用以下5条命令发送E-mail:
HELO,与SMTP服务器握手,传送本机域名;
MAILFROM:,传送发信者的信箱名称;
RCPTTO:,传送接收者的信箱名称;
DATA,发送邮件数据(包括信头和信体);
QUIT,退出与SMTP服务器的连接。
2.试题中直接利用的类及方法如下:
(1)类ServerSocket(int port)实现TCP服务器接口(socket),它提供两种构造函数,用它们来指定服务器插口所用的端口,并监听到达的连接请求。类中的主要方法有:
accept( ):启动服务器插口监听并等待,直到建立连接为止,一旦建立连接就返回Socket类的一个对象。
getInetAddress( ):返回插口所连接的主机地址。
getLocaIPort( ):返回在服务器插口上建立了连接的端口。
close( ):关闭服务器插口。
(2)类InetAddress包装了Internet地址。类中的主要方法有:
getLocaIHost( ):返回一个代表本机Internet地址的InetAddress对象。
getaddress( ):获得数字表示的IP地址。
getHostName( ):获得域名。
(3)类Socket实现基于连接的客户插口。类中的主要方法有getInetAddress( ):返回一个与插口连接的客户机的Internet地址,其类型为InetAd-dress。getlnputStream( ):用来访问与插口相关的输入流。getOutputStream( ):用来访问与插口机关的输出琉。close( ):关闭插口。
(4)readLine( )是输入流类的一个方法,用于服务器或客户从对方读入一行输入流信息。
(5)用户白定义类NVTInputStream(InputStream inStream, OutputStream outStream)实现了网络虚拟终端输入接口。
(6)用户自定义类NVTOutputStream(OutputStream outStream)实现了网络虚拟终端输接口。
3.下面是用Java语言实现的一个简单SMTP服务器程序的部分代码。
[程序代码]
import java.net. *:
import java.io. *;
import jdg. yan. NVTlnputStream; //用户自定义类包
import jdg. yan. NVTOutputStream; //用户自定义类包
public class SMTPServer App

public static void main(String args[])

SMTPServer server=new SMTPServer( );
server. run( );


class SMTPServer

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.");


vold getMail( ) //实现SMTP的子集,从客户接收邮件
out. println("Server220"+hostName+"Ready!");
int state=HELO; //设置状态为HELO,state保存与客户通信的状态
do //接收并处理从邮件客户接收到的命令
String line="";
out. println("Server 250 HELO, OK!");
try
line= (8) ;//从虚拟终端读取一行
if(line==null)state=FINISHED;
catch(IOException ex)
System. out. prmntln("Server IOExceptlon occurred.");
System.exit(1);

switch(state)
case HELO:
if( (9) )//若该行信息为传送本机域名

out. println("Server 250 Hello");
System. out. println(line);
state=MAIL;
else
out. println("Server 500 ERROR");
System. out. println("Server"+line);

state=FINISHED;
break’
case MAIL: //省略代码
case RCPT: //省略代码
case DATA:
if( (10) )//若该行信息为发送邮件数据

out. println("354 mail input; end with.");
System. out. println(line);
state=END_DATA;
else
out. println("500 ERROR");
System. out. println(line);

break;
case END_DATA;//代码省略
case QUIT://代码省略

while(state!=FtNISHED);

//判断客户收到的命令是否与指定的命令字符串相匹配
boolean commandls(String s, String line)
int n=s. length( );
if(s.equalslgnoreCase(line. substring(0.n)))return true;
return false;


答案

参考答案:(A0)commandIs(”DATA”,line)

解析: 若该行信息为发送邮件数据。

完形填空

The afternoon on December 25 in the waiting room, I was the nurse on duty. When I felt sad about having to    1 on Christmas Day, a woman and four small children showed up at my desk.
“Are you all sick?” I asked. “Yes.” the woman said    2  and lowered her head. But when it came to telling me about their    3 , things got a little surprising. They all seemed to be well and there was nothing    4  with their body.
Why did they tell a   5  that they were all sick? I did not say anything but    6  that it might be a little time before a doctor could    7  them . The mother said, “Take your time. We can    8  here. It’s so warm.” When she finished the register chart, I noticed she didn’t write down their address----were they    9 ?
I looked at the    10  around the Christmas tree. The children were excited and    11  to be healthy. The littlest one was pointing at the Christmas tree and said something to the mother. Then I was sure that they came here not because of    12  but only for warmth.
I went back to the nurses’ station and   13  the homeless family. The nurses,    14  about working on Christmas Day like me, turned to feel sorry for the family and decided to    15 .We bought delicious food in the hospital restaurant and    16  a big dinner for our guests. We needed    17 . So we put apples in a basket and collected candies and clothes. Just as we were seriously prepared to meet the physical needs of the    18 , our team worked to meet the needs of a family who just wanted to be    19  on Christmas Day.
Later, as the family was to    20 , the youngest child ran to me and said, “Thank you very much. Good bye. ”
小题1:
A.chooseB.workC.shopD.clean
小题2:
A.angrilyB.joyfullyC.weaklyD.loudly
小题3:
A.plans B.jobsC.habitsD.problems
小题4:
A.wrongB.newC.specialD.strange
小题5:
A.storyB.lieC.jokeD.secret
小题6:
A.explainedB.agreeC.promisedD.replied
小题7:
A.visitB.educateC.seeD.encourage
小题8:
A.sleepB.eatC.danceD.wait
小题9:
A.carelessB.homelessC.impoliteD.unhappy
小题10:
A.familyB.teamC.classD.police
小题11:
A.seemedB.wantedC.decidedD.happened
小题12:
A.funB.hungerC.illnessD.tiredness
小题13:
A.introducedB.mentionedC.reportedD.greeted
小题14:
A.writingB.learningC.worryingD.complaining
小题15:
A.leaveB.stopC.watchD.help
小题16:
A.preparedB.cookedC.orderedD.started
小题17:
A.vegetablesB.materialsC.presentsD.fruits
小题18:
A.doctorsB.patientsC.leadersD.nurses
小题19:
A.satisfiedB.excitedC.warmD.full
小题20:
A.watch B.singC.winD.Leave
单项选择题