Package tk.doraneko.tcp.sendfile.simple
Class Server
- java.lang.Object
-
- tk.doraneko.tcp.sendfile.simple.Server
-
- All Implemented Interfaces:
Runnable
public class Server extends Object implements Runnable
Server cho phép client gửi nhiều file cùng một lúc, sử dụng thread. Ưu: dễ cấu hình. Nhược: ngốm bộ nhớ (heap) nếu dung lượng file lớn, lỗi khi dung lượng file lớn hơn dung lượng khả dụng của pc- Since:
- 13/10/2019
- Author:
- tranphuquy19@gmail.com
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
Server.ServerThread
Thread nhận các file theo từng client
-
Field Summary
Fields Modifier and Type Field Description private int
port
private ServerSocket
serverSocket
private Server.ServerThread
serverThread
private Thread
thread
private String
workingDir
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addThread(Socket socket)
static void
main(String[] args)
private void
open()
void
run()
private void
start()
-
-
-
Field Detail
-
serverSocket
private ServerSocket serverSocket
-
thread
private Thread thread
-
serverThread
private Server.ServerThread serverThread
-
port
private int port
-
workingDir
private String workingDir
-
-
Constructor Detail
-
Server
public Server(int port, String workingDir) throws IOException
- Throws:
IOException
-
-
Method Detail
-
open
private void open() throws IOException
- Throws:
IOException
-
start
private void start()
-
addThread
private void addThread(Socket socket) throws IOException
- Throws:
IOException
-
main
public static void main(String[] args) throws IOException
- Throws:
IOException
-
-