Package ch.qos.logback.classic.net.server

# Class ServerSocketReceiver

java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.classic.net.ReceiverBase
ch.qos.logback.classic.net.server.ServerSocketReceiver

All Implemented Interfaces:
  `ContextAware`, `LifeCycle`

Direct Known Subclasses:
  `SSLServerSocketReceiver`

public class ServerSocketReceiver extends ReceiverBase
A logging socket server that is configurable using Joran.

Author:
  Carl Harris

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`DEFAULT_BACKLOG`
Default `ServerSocket` backlog

### Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase

`context`

## Constructor Summary

Constructors
Constructor
Description
`ServerSocketReceiver()`

## Method Summary

Modifier and Type
Method
Description
`protected ServerListener<ch.qos.logback.classic.net.server.RemoteAppenderClient>`
`createServerListener(ServerSocket socket)`
`protected ServerRunner`
`createServerRunner(ServerListener<ch.qos.logback.classic.net.server.RemoteAppenderClient> listener, Executor executor)`
`String`
`getAddress()`
Gets the local address for the listener.
`int`
`getBacklog()`
Gets the listener queue depth.
`protected InetAddress`
`getInetAddress()`
Gets the local address for the listener.
`int`
`getPort()`
Gets the local port for the listener.
`protected Runnable`
`getRunnableTask()`
Provides the runnable task this receiver will execute.
`protected ServerSocketFactory`
`getServerSocketFactory()`
Gets the server socket factory.
`protected void`
`onStop()`
Allows a subclass to participate in receiver shutdown.
`void`
`setAddress(String address)`
Sets the local address for the listener.
`void`
`setBacklog(int backlog)`
Sets the listener queue depth.
`void`
`setPort(int port)`
Sets the local port for the listener.
`protected boolean`
`shouldStart()`
Starts the server.

### Methods inherited from class ch.qos.logback.classic.net.ReceiverBase

`isStarted, start, stop`

### Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase

`addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### DEFAULT_BACKLOG

public static final int DEFAULT_BACKLOG
Default `ServerSocket` backlog

See Also:
  - Constant Field Values

## Constructor Details

### ServerSocketReceiver

public ServerSocketReceiver()

## Method Details

### shouldStart

protected boolean shouldStart()
Starts the server.

Specified by:
  `shouldStart` in class `ReceiverBase`
Returns:
  flag indicating whether this receiver should start

### createServerListener

protected ServerListener<ch.qos.logback.classic.net.server.RemoteAppenderClient> createServerListener(ServerSocket socket)

### createServerRunner

protected ServerRunner createServerRunner(ServerListener<ch.qos.logback.classic.net.server.RemoteAppenderClient> listener, Executor executor)

### getRunnableTask

protected Runnable getRunnableTask()
Description copied from class: `ReceiverBase`
Provides the runnable task this receiver will execute.

Specified by:
  `getRunnableTask` in class `ReceiverBase`
Returns:
  runnable task

### onStop

protected void onStop()
Allows a subclass to participate in receiver shutdown.

Specified by:
  `onStop` in class `ReceiverBase`

### getServerSocketFactory

protected ServerSocketFactory getServerSocketFactory() throws Exception
Gets the server socket factory.

Subclasses may override to provide a custom factory.

Returns:
  server socket factory
Throws:
  `Exception`

### getInetAddress

protected InetAddress getInetAddress() throws UnknownHostException
Gets the local address for the listener.

Returns:
  an `InetAddress` representation of the local address.
Throws:
  `UnknownHostException`

### getPort

public int getPort()
Gets the local port for the listener.

Returns:
  local port

### setPort

public void setPort(int port)
Sets the local port for the listener.

Parameters:
  `port` - the local port to set

### getBacklog

public int getBacklog()
Gets the listener queue depth.

This represents the number of connected clients whose connections have not yet been accepted.

Returns:
  queue depth
See Also:
  - `ServerSocket`

### setBacklog

public void setBacklog(int backlog)
Sets the listener queue depth.

This represents the number of connected clients whose connections have not yet been accepted.

Parameters:
  `backlog` - the queue depth to set
See Also:
  - `ServerSocket`

### getAddress

public String getAddress()
Gets the local address for the listener.

Returns:
  a string representation of the local address

### setAddress

public void setAddress(String address)
Sets the local address for the listener.

Parameters:
  `address` - a host name or a string representation of an IP address