Thank you, Squee I have to admit that I'm new to UDP :-( and I'm studying the MINA's UDP tutorial from http://mina.apache.org/udp-tutorial.html
If ConnectFuture.isConnected() is always true for UDP, I suggest we describe this behavior in the Javadoc of ConnectFuture as well as in the tutorial. This would be very helpful for the newbie like me :-) On Mon, Dec 29, 2008 at 5:14 PM, Squee <[email protected]> wrote: > While I've never actually used Mina's UDP yet, you need to keep in > mind that UDP doesn't use connections. I believe the Datagram > connector simply does nothing when you "connect" with it; no traffic > is sent to the server. So, a UDP session will always be "connected" > and a connect attempt will always be successful. Or at least, that's > what I assume. > > If you need to know whether you've successfully connected to a server, > use TCP instead (NioSocketConnector). > > On Sun, Dec 28, 2008 at 9:59 AM, hezjing <[email protected]> wrote: > > Hi > > > > I have a method to connect to a UDP server, > > > > private void connect(String hostname, int port) { > > logger.debug("Entered connect()"); > > NioDatagramConnector connector = new NioDatagramConnector(); > > ConnectFuture future = connector.connect(new > > InetSocketAddress(hostname, port)); > > future.awaitUninterruptibly(); > > future.addListener(new IoFutureListener<ConnectFuture>() { > > public void operationComplete(ConnectFuture future) { > > if (future.isConnected()) { > > logger.debug("...connected"); > > } else { > > logger.error("Not connected...exiting"); > > } > > } > > }); > > logger.debug("Exiting connect()"); > > } > > > > > > when run without starting any UDP server (on Windows XP), the program > prints > > the following on the console > > > > Entered connect() > > ...connected > > Exiting connect() > > > > > > Why future.isConnected() returned true while there isn't any server > running? > > > > > > -- > > > > Hez > > > -- Hez
