@Override
  public void handle(Packet packet) throws Exception {
    assert packet.isHeaderSet(Packet.HEADER_BIND);

    BindMessage bind = ioService.getSerializationService().toObject(packet);
    bind(
        (TcpIpConnection) packet.getConn(),
        bind.getLocalAddress(),
        bind.getTargetAddress(),
        bind.shouldReply());
  }
 void sendBindRequest(TcpIpConnection connection, Address remoteEndPoint, boolean replyBack) {
   connection.setEndPoint(remoteEndPoint);
   ioService.onSuccessfulConnection(remoteEndPoint);
   // make sure bind packet is the first packet sent to the end point.
   if (logger.isFinestEnabled()) {
     logger.finest("Sending bind packet to " + remoteEndPoint);
   }
   BindMessage bind = new BindMessage(ioService.getThisAddress(), remoteEndPoint, replyBack);
   byte[] bytes = ioService.getSerializationService().toBytes(bind);
   Packet packet = new Packet(bytes);
   packet.setHeader(Packet.HEADER_BIND);
   connection.write(packet);
   // now you can send anything...
 }