Class AFUNIXSocketServer
java.lang.Object
org.newsclub.net.unix.server.SocketServer<SocketAddress, Socket, ServerSocket>
org.newsclub.net.unix.server.AFUNIXSocketServer
@Deprecated
public abstract class AFUNIXSocketServer
extends SocketServer<SocketAddress, Socket, ServerSocket>
Deprecated.
A base implementation for a simple, multi-threaded socket server.
This class supports both AF_UNIX and "regular" sockets.
- Author:
- Christian Kohlschütter
-
Constructor Summary
ConstructorsConstructorDescriptionAFUNIXSocketServer(ServerSocket serverSocket) Deprecated.Creates a server using the given, boundServerSocket.AFUNIXSocketServer(SocketAddress listenAddress) Deprecated.Creates a server using the givenSocketAddress. -
Method Summary
Modifier and TypeMethodDescriptionprotected ServerSocketDeprecated.Returns a new server socket.booleanstartAndWait(long duration, TimeUnit unit) Deprecated.Methods inherited from class SocketServer
doServeSocket, doSocketClose, getListenAddress, getMaxConcurrentConnections, getServerBusyTimeout, getServerTimeout, getSocketTimeout, isReady, isRunning, onAfterServingSocket, onBeforeServingSocket, onListenException, onListenException, onServerBound, onServerBusy, onServerReady, onServerShuttingDown, onServerStarting, onServerStopped, onServingException, onServingException, onSocketExceptionAfterAccept, onSocketExceptionDuringAccept, onSubmitted, setMaxConcurrentConnections, setServerBusyTimeout, setServerTimeout, setSocketTimeout, start, startAndWaitToBecomeReady, startAndWaitToBecomeReady, startThenStopAfter, stopModifier and TypeMethodDescriptionprotected abstract voiddoServeSocket(Socket socket) Called when a socket is ready to be served.protected voiddoSocketClose(Socket socket) Called upon closing a socket after serving the connection.protected SocketAddressReturns the address the server listens to.intReturns the maximum number of concurrent connections.intReturns the server-busy timeout (in milliseconds).intReturns the server timeout (in milliseconds).intReturns the socket timeout (in milliseconds).booleanisReady()Checks if the server is running and accepting new connections.booleanChecks if the server is running.protected voidonAfterServingSocket(Socket socket) Called after the socket has been served.protected voidonBeforeServingSocket(Socket socket) Called before serving the socket.protected voidDeprecated.protected voidCalled when an exception was thrown while listening on the server socket.protected voidonServerBound(SocketAddress address) Called when the server has been bound to a socket.protected voidonServerBusy(long busyStartTime) Called when the server is busy / not ready to accept a new connection.protected voidonServerReady(int activeCount) Called when the server is ready to accept a new connection.protected voidCalled when the server is shutting down.protected voidCalled when the server is starting up.protected voidonServerStopped(ServerSocket socket) Called when the server has been stopped.protected voidonServingException(Socket socket, Exception e) Deprecated.protected voidonServingException(Socket socket, Throwable t) Called when a throwable was thrown while serving a socket.protected voidonSocketExceptionAfterAccept(Socket socket, SocketException e) Called when aSocketExceptionwas thrown during "accept".protected voidCalled when aSocketExceptionwas thrown during "accept".protected voidonSubmitted(Socket socket, Future<?> submission) Called when a socket gets submitted into the process queue.voidsetMaxConcurrentConnections(int maxConcurrentConnections) Sets the maximum number of concurrent connections.voidsetServerBusyTimeout(int timeout) Sets the server-busy timeout (in milliseconds).voidsetServerTimeout(int timeout) Sets the server timeout (in milliseconds).voidsetSocketTimeout(int timeout) Sets the socket timeout (in milliseconds).voidstart()Starts the server, and returns immediately.voidStarts the server and waits until it is ready or had to stop due to an error.booleanstartAndWaitToBecomeReady(long duration, TimeUnit unit) Starts the server and waits until it is ready or had to stop due to an error.startThenStopAfter(long delay, TimeUnit unit) Requests that the server will be stopped after the given time delay.voidstop()Stops the server.
-
Constructor Details
-
AFUNIXSocketServer
Deprecated.Creates a server using the given, boundServerSocket.- Parameters:
serverSocket- The server socket to use (must be bound).
-
AFUNIXSocketServer
Deprecated.Creates a server using the givenSocketAddress.- Parameters:
listenAddress- The address to bind the socket on.
-
-
Method Details
-
startAndWait
Deprecated.Starts the server and waits until it is ready or had to shop due to an error.- Parameters:
duration- The duration wait.unit- The duration's time unit.- Returns:
trueif the server is ready to serve requests.- Throws:
InterruptedException- If the wait was interrupted.- See Also:
-
newServerSocket
Deprecated.Description copied from class:SocketServerReturns a new server socket.- Specified by:
newServerSocketin classSocketServer<SocketAddress, Socket, ServerSocket>- Returns:
- The new socket (an
AFServerSocketif the listen address is anAFSocketAddress). - Throws:
IOException- on error.
-
SocketServerorAFSocketServer