public class TCPServer extends AbstractServer implements Server
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BACKLOG |
autoClose, DEFAULT_PORT, port, sessionRefCounter, started
Constructor and Description |
---|
TCPServer()
Creates server with default port.
|
TCPServer(int port)
Creates server.
|
TCPServer(int port,
boolean enableNagle)
Creates server.
|
TCPServer(int port,
boolean enableNagle,
String nic)
Creates server.
|
TCPServer(int port,
boolean enableNagle,
String nic,
int sendBufferSize,
int receiveBufferSize)
Creates server.
|
TCPServer(int port,
ServerSocketFactory serverSocketFactory)
Creates server.
|
Modifier and Type | Method and Description |
---|---|
protected ServerSocket |
createServerSocket(int port) |
protected ServerSocket |
createServerSocket(int port,
int backlog,
InetAddress address) |
void |
setIncomingConnectionExecutor(ExecutorService executorService)
Set custom executor service.
|
void |
setIncomingConnectionListener(ConnectionListener listener)
Sets the connection listener.
|
void |
setServerSocketFactory(ServerSocketFactory serverSocketFactory)
Sets server socket factory.
|
void |
start()
Start the server.
|
void |
stop()
Stop server.
|
String |
toString() |
decrementRefCounter, getPort, incrementRefCounter, isAutoClose, isStarted, setAutoClose, setPort, setStarted
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
asAbstract, isAbstract
public static final int DEFAULT_BACKLOG
public TCPServer()
public TCPServer(int port)
port
- - server portpublic TCPServer(int port, ServerSocketFactory serverSocketFactory)
port
- - server portpublic TCPServer(int port, boolean enableNagle)
port
- - server portenableNagle
- - enable/disable nagle algorithmpublic TCPServer(int port, boolean enableNagle, String nic, int sendBufferSize, int receiveBufferSize)
port
- - server portenableNagle
- - enable/disable nagle algorithmsendBufferSize
- send buffer sizereceiveBufferSize
- receive buffer sizepublic TCPServer(int port, boolean enableNagle, String nic)
port
- - server portenableNagle
- - enable/disable nagle algorithmnic
- - specific connection addresspublic void setServerSocketFactory(ServerSocketFactory serverSocketFactory)
serverSocketFactory
- - socket factorypublic void setIncomingConnectionListener(ConnectionListener listener)
Server
setIncomingConnectionListener
in interface Server
listener
- the connection listenerServer.setIncomingConnectionListener(com.epam.common.transport.server.ConnectionListener)
public void setIncomingConnectionExecutor(ExecutorService executorService)
setIncomingConnectionExecutor
in interface Server
executorService
- the executor will be used for working with incoming connections.public void start() throws IOException
Server
start
in interface Server
IOException
- - if error occurredServer.start()
protected ServerSocket createServerSocket(int port, int backlog, InetAddress address) throws IOException
IOException
protected ServerSocket createServerSocket(int port) throws IOException
IOException
public void stop() throws IOException
Server
stop
in interface Server
IOException
- - if error occurredServer.stop()
Copyright © 2000–2022 EPAM Systems. All rights reserved.