public class FileTransferServer
extends java.lang.Object
implements java.lang.Runnable
FileTransferServer is the server responsible for receiving incoming files from clients. port given in the constructor.
If a new socket is established it is given to a FileReceiver, which received the file. | Modifier and Type | Field and Description |
|---|---|
private java.lang.Thread |
fdbServerThread
Thread used by the class.
|
private static org.apache.log4j.Logger |
log
Used to log different events.
|
private java.io.File |
myDataFolder
Folder used to store received files.
|
private java.lang.String |
myFileExtension
Extension which will be assigned to the received files.
|
private java.net.ServerSocket |
myServerSocket
The socket on which the server listens for incoming connections.
|
private boolean |
runFlag
The thread will stop when this flag is
false. |
| Constructor and Description |
|---|
FileTransferServer(int port,
java.lang.String myDataFolderPath,
java.lang.String myFileExtension)
Constructs the object.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
isAlive()
Checks if the thread is alive.
|
void |
run()
Runs the thread.
|
private void |
setDataFolder(java.lang.String dataFolderPath)
Prepares the folder for storing incoming files.
|
void |
start()
Starts the thread.
|
void |
stop()
Stops the thread.
|
private static org.apache.log4j.Logger log
private java.lang.Thread fdbServerThread
private java.net.ServerSocket myServerSocket
private java.io.File myDataFolder
private java.lang.String myFileExtension
private boolean runFlag
false.public FileTransferServer(int port,
java.lang.String myDataFolderPath,
java.lang.String myFileExtension)
throws java.io.IOException
port - port on which the server listens for incoming connnectionsmyDataFolderPath - folder used to store received filesmyFileExtension - extension assigned to the received filesjava.io.IOException - if a communication problem occurspublic void start()
public void stop()
public boolean isAlive()
true if the thread is alive, false otherwiseprivate void setDataFolder(java.lang.String dataFolderPath)
throws java.io.IOException
dataFolderPath - folder used to store received filesjava.io.IOException - if a communication problem occurspublic void run()
FileReceiver.run in interface java.lang.Runnable