📄 httpconnection.java
字号:
package dli2fe.http;
/**
* Title: Digial Library Interoperable Interface Fudan Edition
* Description: This project contains all the classes required for DLI2FE interface. Developers use these classes to implement the wrapper and client side codes. The basic functions of DLI2FE is as follows:
* Search: Search a digital library source site.
* Metadata: Fetch metadata for a site.
* ResultAccess: Get results for a given query.
* DLI2FE uses Dublin Core as the basic attribute model, DAV/DASL as the general XML-based query language and CORBA as distributed object transportation mechanism.
* Copyright: Copyright (c) 2001
* Company: Fudan University
* @author Carl Tao
* @version 1.0
*/
import java.io.*;
import java.net.*;
import java.util.*;
/**
* A new Connection object is created for each new connection
* established between the server and a client.
*
* @author Sergey Melnik <melnik@db.stanford.edu>
*/
public class HTTPConnection extends Thread {
HTTPServer http;
Socket socket;
InputStream in;
OutputStream out;
// The communication streams are initiated and the thread is started.
HTTPConnection(HTTPServer http, Socket socket, ThreadGroup threadgroup, int priority) {
// The Connection thread is given a group, a name, and a priority.
super(threadgroup, "HTTP Connection");
// System.out.println("New connection from " + client_socket);
this.http = http;
this.setPriority(priority);
this.socket = socket;
// The data-exchange streams are created.
try {
in = socket.getInputStream();
out = socket.getOutputStream();
// in = new BufferedInputStream(socket.getInputStream());
// out = new BufferedOutputStream(socket.getOutputStream());
} catch (IOException e) {
try {
socket.close();
} catch (IOException e2) { ; }
System.err.println(http + " Exception while getting socket streams: " + e);
return;
}
// The Connection thread is started.
this.start();
}
public InputStream getInputStream() {
return in;
}
public OutputStream getOutputStream() {
return out;
}
public void run() {
try {
http.getCallback().process(socket, in, out);
} catch (Exception any) {
System.err.println(toString() + " ERROR: " + any);
any.printStackTrace(System.err);
} finally {
try {
// System.err.println(http + " Hanging up connection.");
socket.close();
} catch (IOException sock) {}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -