Package com.github.kokorin.jaffree.net
Class TcpServer
java.lang.Object
com.github.kokorin.jaffree.net.TcpServer
- All Implemented Interfaces:
ProcessHelper,Closeable,AutoCloseable,Runnable
- Direct Known Subclasses:
FtpServer,NegotiatingTcpServer
Abstract TCP Server implementing
ProcessHelper.
This class is intended to be used in different ffmpeg Input & Output
implementations which interact with ffmpeg via TCP sockets.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static ServerSocketAllocatesServerSocketon random port of loopback network interface.voidclose()Closes underlying TCP Socket.protected final voidfinalize()Returns string representation of host and port.final voidrun()protected abstract voidServes TCP connection.toString()
-
Constructor Details
-
TcpServer
Creates TCP server.This implementation is not intended to be used anywhere except this project. It servers only the first accepted connection in single thread.
- Parameters:
serverSocket- server socket to accept connection. Pay attention that server socket should listen on loopback (127.0.0.1) address for security reasons.
-
-
Method Details
-
run
public final void run() -
serve
Serves TCP connection.- Parameters:
socket- TCP socket- Throws:
IOException- socket IO exception
-
finalize
-
close
Closes underlying TCP Socket.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- if any IO error
-
getAddressAndPort
Returns string representation of host and port.- Returns:
- host and port string
-
toString
-
allocateSocket
AllocatesServerSocketon random port of loopback network interface.- Returns:
- ServerSocket
-