Class FtpServer

java.lang.Object
com.github.kokorin.jaffree.net.TcpServer
com.github.kokorin.jaffree.net.FtpServer
All Implemented Interfaces:
ProcessHelper, Closeable, AutoCloseable, Runnable

public class FtpServer extends TcpServer
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 Details

    • FtpServer

      protected FtpServer(ServerSocket controlServerSocket, SeekableByteChannel channel, int bufferSize)
      Creates FtpServer.
      Parameters:
      controlServerSocket - server socket to establish FTP control connection
      channel - channel to read from or write to
      bufferSize - size of buffer to copy data to or from Channel
  • Method Details

    • serve

      protected void serve(Socket controlServerSocket) throws IOException
      Serves FTP using passed in Socket for control connection.
      Specified by:
      serve in class TcpServer
      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 input
      controlOutput - control output
      dataServerSocket - server socket for data transfer
      Throws:
      IOException - socket IO exception
    • doGreet

      protected void doGreet(OutputStream output) throws IOException
      Sends greet response after establishing control connection.
      Parameters:
      output - output to write response
      Throws:
      IOException - socket IO exception
    • doUser

      protected void doUser(OutputStream output, String args) throws IOException
      Sends response to USER control command.
      Parameters:
      output - output to write response
      args - arguments, ignored
      Throws:
      IOException - socket IO exception
    • doNotImplemented

      protected void doNotImplemented(OutputStream output) throws IOException
      Sends response to non-implemented control commands.
      Parameters:
      output - output to write response
      Throws:
      IOException - socket IO exception
    • onRandomPorts

      public static FtpServer onRandomPorts(SeekableByteChannel channel)
      Creates FtpServer waiting for TCP connection on random port.
      Parameters:
      channel - byte channel to serve data
      Returns:
      FtpServer
    • onRandomPorts

      public static FtpServer onRandomPorts(SeekableByteChannel channel, int bufferSize)
      Creates FtpServer waiting for TCP connection on random port.
      Parameters:
      channel - byte channel to serve data
      bufferSize - buffer size to copy bytes
      Returns:
      FtpServer