?? ftpserver.java
字號:
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package server.ftp;
import java.io.File;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import server.BaseServer;
/**
* This is ftp server starting point. For each request it
* instantiates a new <code>BaseFtpConnection</code> object.
*
* @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
*/
public
class FtpServer extends BaseServer {
// server name
public final static String NAME = "FTP";
// configuration object
private FtpConfig mConfig;
// pasv server socket
private ServerSocket mPasvSocket;
//////////////////////////////////////////////
/**
* Constructor.
* @param configFile this ftp server configuration file.
*/
public FtpServer(File configFile) throws Exception {
mConfig = new FtpConfig(configFile);
}
/**
* Get server port.
*/
public int getServerPort() {
return mConfig.getServerPort();
}
/**
* Get server bind address.
*/
public InetAddress getServerAddress() {
return mConfig.getServerAddress();
}
/**
* Get server name.
*/
public String getServerName() {
return NAME;
}
/**
* Serves threaded request.
*/
public void serveRequest(Socket soc) {
BaseFtpConnection ftpCon = new FtpConnection(mConfig, soc);
new Thread(ftpCon).start();
}
/**
* Stop all currently executing threads.
*/
public void dispose() {
if (mConfig != null) {
mConfig.dispose();
mConfig = null;
}
}
/**
* Get the configuration object.
*/
public FtpConfig getConfig() {
return mConfig;
}
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
/**
* Command line ftp server starting point.
*/
/* public static void main(String args[]) {
// input argument check
if(args.length != 1) {
System.err.println("Usage: java server.ftp.FtpServer <config file>");
System.exit(1);
}
try {
BaseServer server = new FtpServer(new File(args[0]));
final ServerEngine engine = new ServerEngine(server);
// // add shutdown hook - since JDK1.3
// Runnable shutdownHook = new Runnable() {
// public void run() {
// System.out.println("Stopping server...");
// engine.stopServer();
// }
// };
// Runtime.getRuntime().addShutdownHook(new Thread(shutdownHook));
engine.startServer();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
*/
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -