52 lines
1.1 KiB
Java
52 lines
1.1 KiB
Java
|
|
import java.io.*;
|
|
import java.net.*;
|
|
import java.util.*;
|
|
|
|
public class FileServer implements Runnable
|
|
{
|
|
private int m_port;
|
|
private String m_rootPath;
|
|
private ServerSocket m_serverSocket;
|
|
|
|
public FileServer(int port, String rootPath)
|
|
{
|
|
m_port = port;
|
|
m_rootPath = rootPath;
|
|
}
|
|
|
|
public void run()
|
|
{
|
|
try {
|
|
m_serverSocket = new ServerSocket(m_port);
|
|
|
|
/* porcess connection requests */
|
|
for (;;)
|
|
{
|
|
Socket clientSocket = m_serverSocket.accept();
|
|
|
|
Thread thread = new Thread(new FileHandler(clientSocket));
|
|
thread.start();
|
|
}
|
|
} catch (IOException ioe) {
|
|
System.out.println("KaZaClient: IO Exception!");
|
|
ioe.printStackTrace();
|
|
return;
|
|
}
|
|
}
|
|
|
|
private class FileHandler implements Runnable
|
|
{
|
|
private Socket m_socket;
|
|
|
|
public FileHandler(Socket socket)
|
|
{
|
|
m_socket = socket;
|
|
}
|
|
|
|
public void run()
|
|
{
|
|
}
|
|
}
|
|
}
|