/**
  * Transfers attributes such as (de)serializers, singleUse etc to a new connection. When the
  * connection factory has a reference to a TCPListener (to read responses), or for single use
  * connections, the connection is executed. Single use connections need to read from the
  * connection in order to close it after the socket timeout.
  *
  * @param connection The new connection.
  * @param socket The new socket.
  */
 protected void initializeConnection(TcpConnection connection, Socket socket) {
   TcpListener listener = this.getListener();
   if (listener != null) {
     connection.registerListener(listener);
   }
   TcpSender sender = this.getSender();
   if (sender != null) {
     connection.registerSender(sender);
   }
   connection.setMapper(this.getMapper());
   connection.setDeserializer(this.getDeserializer());
   connection.setSerializer(this.getSerializer());
   connection.setSingleUse(this.isSingleUse());
 }