com.kuka.comm.net
Class TcpConnectionHandler

java.lang.Object
  extended by com.kuka.comm.net.NetConnectionHandler<TcpServer,TcpConnection,Socket>
      extended by com.kuka.comm.net.TcpConnectionHandler

public class TcpConnectionHandler
extends NetConnectionHandler<TcpServer,TcpConnection,Socket>

This class is responsible for handling incoming connection requests at a TCP server.

Override #acceptConnection(TcpServer, Socket) to decide whether an incoming request is accepted. The default implementation accepts all requests.


Constructor Summary
TcpConnectionHandler(TcpConnectionConfigurator configurator)
          Creates a new TCP connection handler that accepts an unlimited number of connections and uses the given configurator to configure the connection.
TcpConnectionHandler(TcpConnectionConfigurator configurator, int maxConnections)
          Creates a new TCP connection handler that uses the given configurator to configure incoming connections and limits the maximum number of active connections to maxConnections.
 
Method Summary
protected  TcpConnection createConnection(TcpServer server, Socket socket)
          Creates a new connection for an incoming connection request.
 
Methods inherited from class com.kuka.comm.net.NetConnectionHandler
acceptConnection, getConfigurator, getMaxConnections, handleConnection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TcpConnectionHandler

public TcpConnectionHandler(TcpConnectionConfigurator configurator)
Creates a new TCP connection handler that accepts an unlimited number of connections and uses the given configurator to configure the connection.

Parameters:
configurator - the configurator used to configure incoming connections, must not be null

TcpConnectionHandler

public TcpConnectionHandler(TcpConnectionConfigurator configurator,
                            int maxConnections)
Creates a new TCP connection handler that uses the given configurator to configure incoming connections and limits the maximum number of active connections to maxConnections.

Parameters:
maxConnections - the maximum number of simultaneous connections, must be greater than 0
configurator - the configurator used to configure incoming connections, must not be null
Method Detail

createConnection

protected final TcpConnection createConnection(TcpServer server,
                                               Socket socket)
Description copied from class: NetConnectionHandler
Creates a new connection for an incoming connection request.

Specified by:
createConnection in class NetConnectionHandler<TcpServer,TcpConnection,Socket>
Parameters:
server - the server receiving the incoming connection request
socket - object that can be used to identify the incoming connection request
Returns:
a connection object managing the incoming request


Copyright © 2019. All rights reserved.