Article View: cn.bbs.comp.lang.java
Article #23842Re: Connecting to an NNTP Server...
From: Phil Hanna
Date: Wed, 04 Jul 2001 21:46
Date: Wed, 04 Jul 2001 21:46
52 lines
3875 bytes
3875 bytes
On Mon, 2 Jul 2001 20:46:55 -0600, "Randy K. Secrist" <r.secrist@m.cc.utah.edu> wrote: >This is a great newsgroup question - since it deals with connecting to >newsgroups.... > >I am writing a nntp client using java, and have a few options. I could use >the java.net.Socket class to socket the connection and handle all >input/output one byte at a time, but I don't want to reinvent the wheel. I >noticed a javax.mail.internet.NewsGroup class, however it is basically just >a container for a newsgroup - nothing that deals with establishing the >connection. > >So - I was thinking - JNDI - connecting using the same method which I have >used to connect to LDAP - bind to a context, yada yada yada - but I haven't >ever done this with anything BUT Ldap, and can't find any good documentation >on using JNDI with nntp. > >Does anyone have any other ideas - suggestions? Or, should I dig in, socket >the connection and reinvent the wheel? I already did this for SMTP - then >found out about javamail later... :) Being a student, I am young and am use >to creating wheels from squares - but must I do it the hard way everytime? > Depends entirely on what you want to get out of this. Just because somebody else has written a class, it doesn't mean you're "reinventing the wheel". A wheel is a fundamental bit of technology that is interchangable in most contexts. Very little end-user software fits that description. You can hunt around the internet for somebody's NNTP class and hope it does what you need. If it has bugs, or if it doesn't handle certain message types, or whatever, it's your problem. If you don't know conceptually what's going on under the covers, good luck fixing it. In my own opinion, something as (relatively) simple as an NNTP reader is worth doing yourself. It is fully documented in RFC 977, which you can get from http://www.freesoft.org/CIE/RFC/977/index.htm, among other places. Without reading the protocol spec, you don't know what features are there or how they interrelate. Programming with sockets does not mean working at the byte level. That's not how text protocols like NNTP, POP, and SMTP work. You can use telnet to manually interact with a server in full lines of ASCII text terminated with CRLF. A software client is just one simple step above that. After you have opened a socket to the server, you can get its input and output streams and wrap them in BufferedReader and PrintWriter, respectively, to allow you to use readLine() and println() for your interaction. -- Phil Hanna Author of JSP: The Complete Reference http://www.philhanna.com
Technical Details
Message-ID:
<3b438ab7.162930952@news.ipass.net>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.mathworks.com!feeder.qis.net!sn-xit-02!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mailReferences:
<Ama07.841$n72.540160@news.uswest.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f5d71,903b09b806c83a2f X-Google-Attributes: gidf5d71,public X-Google-Thread: f6cb0,903b09b806c83a2f X-Google-Attributes: gidf6cb0,public X-Google-Thread: 111d6b,903b09b806c83a2f X-Google-Attributes: gid111d6b,public X-Google-Thread: 10a146,903b09b806c83a2f X-Google-Attributes: gid10a146,public X-Google-Thread: 113ae9,903b09b806c83a2f X-Google-Attributes: gid113ae9,public X-Google-ArrivalTime: 2001-07-04 14:40:09 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.mathworks.com!feeder.qis.net!sn-xit-02!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: pehanna@yahoo.com (Phil Hanna) Newsgroups: cn.bbs.comp.lang.java,comp.lang.java,comp.lang.java.help,comp.lang.java.misc,comp.lang.java.programmer Subject: Re: Connecting to an NNTP Server... Date: Wed, 04 Jul 2001 21:46:11 GMT Organization: Posted via Supernews, http://www.supernews.com Message-ID: <3b438ab7.162930952@news.ipass.net> References: <Ama07.841$n72.540160@news.uswest.net> X-Newsreader: Forte Free Agent 1.21/32.243 X-Complaints-To: newsabuse@supernews.com Lines: 52