Greetings All,
I have a FileSender Application that sends data to a server via a
FileHandler (not shown here, but in previous post). All data is
successfully sent and received, but to keep the FileSenderHandler from
terminating early, I had to use the following statement:
f.channel().closeFuture().sync(); in the FileSender.java Application (the
main application) which blocks the main program preventing it from
terminating as well as the FileSenderHandler Application. *My Question is:* HOW
CAN I CLOSE THE CHANNEL AND UNBLOCK THE MAIN FileSender APPLICATION ONCE
THE FileSenderHandler HAS SUCCESSFULLY SENT AND ACKNOWLEDGED ALL DATA? I
currently can't do it within the FileSender class because the application
is blocked at that point. I tried closing the channel within the
FileSenderHandler class by doing ctx.channel().close() which I thought
would unblock the FileSender App since the App is waiting on the close
channel event but that didn't work, I also tried closing the channel on the
receiver/server side by doing ctx.channel().close() within the
FileReceiverHandler but that still didn't unblock the FileSender App. Any
help or suggestions would be greatly appreciated.
*FileSender.java -* *Bootstraps the channel and connects this client/host
to another host*
public static void main(String[] args) throws Exception {
// Configure the client/ File Sender
EventLoopGroup group = new NioEventLoopGroup();
try {
Bootstrap b = new Bootstrap();
b.group(group)
.channel(NioSocketChannel.class)
.option(ChannelOption.TCP_NODELAY, true)
.handler(new FileSenderInitializer());
// Start the client.
ChannelFuture f = b.connect(HOST, PORT).sync();
// Wait until the connection is closed.
f.channel().closeFuture().sync();
} finally {
// Shut down the event loop to terminate all threads.
group.shutdownGracefully();
}
}
}
--
You received this message because you are subscribed to the Google Groups
"Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/netty/c0fe875e-1551-4e0d-853b-b367dbed74a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.