Bonjour,
Je r�alise actuellement une architecture client-serveur � l'aide de Netty. J'ai un serveur Netty mais je n'arrive pas � comprendre comment r�cup�rer le channel cr�� par le serveur pour t�l�charger un fichier. Le client est soit en Netty soit en Java, j'enqu�te sur les deux pistes.
Merci pour votre r�ponse.
Voici le code de mon serveur:
public void start() throws Exception {
final SslContext sslCtx;
sslCtx = null;
bossGroup = new NioEventLoopGroup(1);
workerGroup = new NioEventLoopGroup();
ServerBootstrap boot = new ServerBootstrap();
boot.group(bossGroup, workerGroup);
boot.channel(NioServerSocketChannel.class);
boot.childHandler(new NettyServerInitializer(sslCtx));
chan = boot.bind(new InetSocketAddress("127.0.0.1",port)).sync().channel();
// System.out.println(chan.toString());
}
/**
* Method to stop the server.
*
* @throws Exception if an exception occurs.
*/
public void stop() throws Exception {
chan.closeFuture().sync();
bossGroup.shutdownGracefully();
workerGroup.shutdownGracefully();
}
/**
* Method to launch the server.
*
* @param args: no args.
*/
public static void main(String... args) {
try {
new NettyServer().start();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("API started on port {}", port);
}
} catch (final Exception e) {
LOGGER.error("Unable to start API server", e);
}
}
Partager