Package com.github.kokorin.jaffree.net
Class FtpServer
java.lang.Object
com.github.kokorin.jaffree.net.TcpServer
com.github.kokorin.jaffree.net.FtpServer
- All Implemented Interfaces:
ProcessHelper,Closeable,AutoCloseable,Runnable
Simple FTP server intended to work only with ffmpeg.
This class is not intended to be used as production FTP server since it uses knowledge of how ffmpeg operates with FTP input & output.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFtpServer(ServerSocket controlServerSocket, SeekableByteChannel channel, int bufferSize) CreatesFtpServer. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoGreet(OutputStream output) Sends greet response after establishing control connection.protected voiddoNotImplemented(OutputStream output) Sends response to non-implemented control commands.protected voiddoUser(OutputStream output, String args) Sends response to USER control command.static FtpServeronRandomPorts(SeekableByteChannel channel) CreatesFtpServerwaiting for TCP connection on random port.static FtpServeronRandomPorts(SeekableByteChannel channel, int bufferSize) CreatesFtpServerwaiting for TCP connection on random port.protected voidoperate(BufferedReader controlReader, OutputStream controlOutput, ServerSocket dataServerSocket) Operates as FTP server: accepts control commands via controlReader, sends control responses via controlOutput, uses dataServerSocket for data transfer.protected voidServes FTP using passed inSocketfor control connection.Methods inherited from class com.github.kokorin.jaffree.net.TcpServer
allocateSocket, close, finalize, getAddressAndPort, run, toString
-
Constructor Details
-
FtpServer
CreatesFtpServer.- Parameters:
controlServerSocket- server socket to establish FTP control connectionchannel- channel to read from or write tobufferSize- size of buffer to copy data to or from Channel
-
-
Method Details
-
serve
Serves FTP using passed inSocketfor control connection.- Specified by:
servein classTcpServer- Parameters:
controlServerSocket- socket with established control connection- Throws:
IOException- socket IO exception
-
operate
protected void operate(BufferedReader controlReader, OutputStream controlOutput, ServerSocket dataServerSocket) throws IOException Operates as FTP server: accepts control commands via controlReader, sends control responses via controlOutput, uses dataServerSocket for data transfer.- Parameters:
controlReader- control inputcontrolOutput- control outputdataServerSocket- server socket for data transfer- Throws:
IOException- socket IO exception
-
doGreet
Sends greet response after establishing control connection.- Parameters:
output- output to write response- Throws:
IOException- socket IO exception
-
doUser
Sends response to USER control command.- Parameters:
output- output to write responseargs- arguments, ignored- Throws:
IOException- socket IO exception
-
doNotImplemented
Sends response to non-implemented control commands.- Parameters:
output- output to write response- Throws:
IOException- socket IO exception
-
onRandomPorts
CreatesFtpServerwaiting for TCP connection on random port.- Parameters:
channel- byte channel to serve data- Returns:
- FtpServer
-
onRandomPorts
CreatesFtpServerwaiting for TCP connection on random port.- Parameters:
channel- byte channel to serve databufferSize- buffer size to copy bytes- Returns:
- FtpServer
-