Is the URLConnection class capable of being subclassed to createcustom protocol connections?

Discussion in 'Java' started by -, Jul 23, 2005.

  1. -

    - Guest

    Is the URLConnection class capable of being subclassed to create custom
    protocol connections? Protocol in this case refers to ANY and ALL
    protocol specified in RFC, e.g ftp, news, smtp, irc, nntp, and several
    hundreds more or so....

    If yes, should i use it or connect using the old fashion way of using
    io/nio?
    -, Jul 23, 2005
    #1
    1. Advertising

  2. -

    Simon OUALID Guest

    Why not choosing to use the Jakarta/Apache Commons Net libraries ? It
    works very well.

    http://jakarta.apache.org/commons/net/

    - wrote:
    > Is the URLConnection class capable of being subclassed to create custom
    > protocol connections? Protocol in this case refers to ANY and ALL
    > protocol specified in RFC, e.g ftp, news, smtp, irc, nntp, and several
    > hundreds more or so....
    >
    > If yes, should i use it or connect using the old fashion way of using
    > io/nio?
    Simon OUALID, Jul 23, 2005
    #2
    1. Advertising

  3. - wrote:
    > Is the URLConnection class capable of being subclassed to create custom
    > protocol connections? Protocol in this case refers to ANY and ALL
    > protocol specified in RFC, e.g ftp, news, smtp, irc, nntp, and several
    > hundreds more or so....
    >
    > If yes, should i use it or connect using the old fashion way of using
    > io/nio?


    I think you want a custom URLStreamHandler. See the javadoc for the URL
    constructor

    public URL(String protocol,
    String host,
    int port,
    String file)
    throws MalformedURLException

    for configuration details.

    HTH,
    Ray

    --
    XML is the programmer's duct tape.
    Raymond DeCampo, Jul 23, 2005
    #3
  4. Re: Is the URLConnection class capable of being subclassed to create custom protocol connections?

    "-" <> wrote
    > Is the URLConnection class capable of being subclassed to create custom
    > protocol connections? Protocol in this case refers to ANY and ALL
    > protocol specified in RFC, e.g ftp, news, smtp, irc, nntp, and several
    > hundreds more or so....

    Yes (and the built-in protocols are implemented in exactly this manner)

    See <http://doc.novsu.ac.ru/oreilly/java/exp/ch09_06.htm> for a real-world
    example.
    (This book is still very useful, although a bit out-dated. It wrote "package
    net.www.protocol" where Sun now uses "package sun.net.www.protocol")
    >
    > If yes, should i use it or connect using the old fashion way of using
    > io/nio?


    --
    "TFritsch$t-online:de".replace(':','.').replace('$','@')
    Thomas Fritsch, Jul 24, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2xpbWVtYW4=?=

    Cannot view subclassed Page in Visual Designer

    =?Utf-8?B?U2xpbWVtYW4=?=, Jul 15, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    482
    =?Utf-8?B?U2xpbWVtYW4=?=
    Jul 20, 2005
  2. Benji
    Replies:
    1
    Views:
    460
    Chris Uppal
    Oct 6, 2005
  3. Replies:
    10
    Views:
    1,520
    Roedy Green
    Oct 19, 2005
  4. Replies:
    20
    Views:
    2,200
  5. Replies:
    2
    Views:
    3,597
Loading...

Share This Page