Package var.sockets.tcp.filer
Class FileServerThreadPool
- java.lang.Object
-
- var.sockets.tcp.filer.FileServerThreadPool
-
public class FileServerThreadPool extends java.lang.Object
threaded server for var.sockets.tcp.filer File service. waits for clients to connect. Upon connection sends concurrently to other client connections a manually defined file back to client. closes the connection directly afterwards.- Author:
- Sandro Leuchter
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
FileServerThreadPool.FileThread
Each connection is handled with an instance of this class.
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
FILE
path to file which will be sent to clients; relative to current working directory (e.g.private int
port
port on which this service is currently listening on localhostprivate java.util.concurrent.Executor
threadPool
thread pool of this server
-
Constructor Summary
Constructors Constructor Description FileServerThreadPool(int port)
the only constructor for this class
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
main(java.lang.String[] args)
main method: entrypoint to run servicevoid
start()
creates server socket on localhost:port, infinitely handles connections to clients concurrently
-
-
-
Field Detail
-
FILE
private static final java.lang.String FILE
path to file which will be sent to clients; relative to current working directory (e.g. project root)- See Also:
- Constant Field Values
-
port
private final int port
port on which this service is currently listening on localhost
-
threadPool
private final java.util.concurrent.Executor threadPool
thread pool of this server
-
-
Constructor Detail
-
FileServerThreadPool
public FileServerThreadPool(int port)
the only constructor for this class- Parameters:
port
- port on which this service will be listening on localhost
-
-
Method Detail
-
start
public void start()
creates server socket on localhost:port, infinitely handles connections to clients concurrently
-
main
public static void main(java.lang.String[] args)
main method: entrypoint to run service- Parameters:
args
- args[0] must be the port number of the server (int); rest of args is ignored
-
-