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
>

Reply via email to