资源简介
卡耐基 SSD8答案(全 exam+qiuz+excerise)
代码片段和文件信息
package exercise2;
//200532580182 pengxu
import java.io.*;
import java.net.*;
public class ModifiedClient {
//the client socket used to connect to server
private Socket clientSocket;
//read the user input from keyboard
BufferedReader inFromKeyBoard;
//get the information response by the server
BufferedReader inFromServer;
//send the user input to the sever
DataOutputStream outToServer;
public ModifiedClient(){
this.clientSocket=null;
}
//connect to the server
public void connect(String hostint port){
try{
this.clientSocket=new Socket(hostport);
//read from keyboard
this.inFromKeyBoard=new BufferedReader
(new InputStreamReader(System.in));
//read from the client socket
this.inFromServer=new BufferedReader
(new InputStreamReader(clientSocket.getInputStream()));
//output to server socket
this.outToServer=new DataOutputStream
(clientSocket.getOutputStream() );
}catch(Exception e){
e.printStackTrace();
}
}
public void close(){
try{
//close the socket
this.clientSocket.close();
}catch(Exception e){
e.printStackTrace();
}
}
public static void main(String [] args) throws Exception{
if(args.length!=1){
System.out.println(“Usage: Client “);
System.exit(0);
}
else{
try{
double sendBytes;
double recieveBytes;
final int port=80;
ModifiedClient client=new ModifiedClient();
//connnect to the user defined host(argv[0]) use port 80
client.connect(args[0] port);
System.out.println(args[0] + “ is listening to you request:“);
//read the user input from keyboard assign to s
String s=client.inFromKeyBoard.readLine();
s+=“\r\n“ + “\r\n“;
//send s to server
client.outToServer.writeBytes(s);
//get the sendBytes
sendBytes=s.length();
//get the response header and show to the user
String file=““;
String temp=file;
int i=0;
boolean flag=true;
for(int j=0; flag&&((j=client.inFromServer.read())!=-1);){
switch(j)
{
case 13: // ‘\r‘
break;
case 10: // ‘\n‘
if(j == i)
{
flag = false;
} else
{
i = j;
file+=“\r\n“;
}
break;
default:
i = j;
file+=(char)j;
break;
}
}
System.out.println(“Header:“);
System.out.println(““);
System.out.println(file);
//get the recieveBytes
recieveBytes=file.length();
file=““;
temp=client.inFromServer.readLine();
//get the response context
while(temp!=null){
file=file + “\r\n“+temp;
temp=client.inFromServer.readLine();
}
// save the response text to a file
System.ou
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3476 2010-03-21 23:27 Modified---Client.java
文件 14577 2010-03-21 23:25 ssd8+===+exam3.rar
文件 9585 2010-03-21 23:28 ssd8+EXAM1+选择题---+Multiple-Choice.txt
文件 10388 2010-03-21 23:24 ssd8+---exercise1.rar
文件 139016 2010-03-21 23:16 SSD8-==-=-Exam3.rar
文件 10194 2010-03-21 23:18 SSD8=-=-Exercise1.rar
文件 4697 2010-03-21 23:30 ssd8---E1.rar
文件 21455 2010-03-21 23:25 ssd8---exam3.rar
文件 21726 2010-03-21 23:23 ssd8----exam3.rar
文件 7603 2010-03-21 23:21 ssd8----exam11.txt
文件 3563 2010-03-21 23:20 ssd8--exercise4.rar
文件 8670 2010-03-21 23:16 ssd8---exercise1.rar
文件 4169 2010-03-21 23:17 ssd8---exercise2.rar
文件 4447 2010-03-21 23:19 ssd8----exercise5.rar
文件 8691 2010-03-21 23:26 WebProxyServer0000.java
文件 389895 2010-04-11 19:29 choice.txt
----------- --------- ---------- ----- ----
662152 16
相关资源
- 卡耐基 SSD7答案(全 exam+qiuz+excerise)
- 实战Linux编程精髓源代码
- myexam.zip
- Source Code Examples-Spring Boot in Action;
- swfUpload最新版本2.5 swf + js + example
- exam_formatter_2_setup.exe
- TSF 输入法开发 TSF example
- iTween+Examples
- Vue.js 2.x by Example
- ROS by example
- Tkinter GUI Programming By Example 无水印转化
- Probability: Theory and Examples答案
- Kinect v2 Examples with MS-SDK 2017年6月最新
- PyQt examples
- UVM实战参考代码 example_and_uvm_source_c
- xjview工具箱使用视频-xjview example.tar
- Certified Reliability Engineer Exam Preparatio
- exam_formatter_3_setup.exe
- MCSD Certification Toolkit (Exam 70-483)
- Linux-期末考试试题8套(含答案)
- ros by example for indigo volume 2
- DocX v1.0.0.10 开发文档- Documentation and
- MBT_example_createobj.jpg
- 卡耐基 SSD1答案(全 eaxm+qiuz+excerise)
- mvn-examples-1.0.zip
- ssd8 exam2
评论
共有 条评论