資源簡介
使用http1.0協議,實現一個非常簡單的http web server和client
代碼片段和文件信息
import?java.io.*;
import?java.net.*;
import?java.util.*;
public?class?TCPClient?{
static?TCPClient?client;
private?static?final?int?SERVICE_PORT_3496?=?8000;
public?static?void?main(String?args[])?throws?Exception?{
??if?(args.length?==?0)?{
????client?=?new?TCPClient(“www.neu.edu.cn“?SERVICE_PORT_3496?);
????client.run();
???}?else?if(args.length?==?1)?{
????client?=?new?TCPClient(args[0]?SERVICE_PORT_3496);
????client.run();
???}else?{
????System.out.println(“ERROR.You?should?input?as?below?java?Client?host?port?or?java?Client“);
???}
}
private?String?addr;
private?int?port;
public?TCPClient(String?host?int?port)?{
???this.addr?=?host;
???this.port?=?port;
}
public?void?run(){
???Socket?socket;
???BufferedInputS
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-05-28?18:53??httpclient&server\
?????文件????????4414??2010-04-15?19:55??httpclient&server\TCPClient.java
?????文件????????5605??2010-04-13?23:57??httpclient&server\TCPServer.java
- 上一篇:Java版象棋
- 下一篇:jsp數據庫實驗報告管理系統
評論
共有 條評論