用于连接到 NNTP 服务器的 java Socket 或 DatagramSocket

发布于 2024-08-19 11:45:34 字数 319 浏览 6 评论 0原文

大家好,我想编写一个简单的 NNTP 客户端,它可以连接到服务器,发送 AUTHINFO 详细信息,并使用 GROUP 和 BODY 加入组并检索帖子。

我在这里与几个人进行了讨论,他们建议使用 dataGramSockets 和 datGramPackets。

谁能提供一个简单的脚本来解释每个命令的工作原理以及为什么使用 DataGram Sockets 而不是传统的 Sockets?我使用 Socket 并且能够连接到我的服务器,但我不知道如何使用 getInputStream() 和 getOutputStream() 向服务器发送/接收数据。

任何帮助都会很棒。

Hay Guys, i want to write a simple NNTP client, which can connect to a server, send AUTHINFO details, and use GROUP and BODY to join a group and retreive posts.

I had a discussion with a couple of guys in here and they suggested using dataGramSockets and datGramPackets.

Could anyone provide a simple script to do these explaining how each command works and why use DataGram Sockets over the tradtional Socket? I used Socket and was able to connect to my server, but i hadn't a clue how to use getInputStream() and getOutputStream() to send/receive data to the server.

Any help would be great.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

又怨 2024-08-26 11:45:34

NNTP 不是基于 TCP 的协议吗?我认为数据报在这里不合适。有关详细信息,请参阅 RFC。使用此协议。

我看到 Apache Commons Net 提供 an NNTP包,可能有用。

NNTPClient 封装了所有
发布和发布所需的功能
从 NNTP 服务器检索文章。
与派生自的所有类一样
SocketClient,必须先连接
之前连接到服务器
做任何事情,最后
完全断开连接()后
完成与服务器的交互。
请记住 isAllowedToPost()
方法在NNTP中定义。

如果有人已经完成了这项艰苦的工作,我会避免使用原始套接字。

Isn't NNTP a TCP-based protocol ? I don't think datagrams would be appropriate here. See the RFC for further info re. using this protocol.

I see that Apache Commons Net offer an NNTP package, which may be of use.

NNTPClient encapsulates all the
functionality necessary to post and
retrieve articles from an NNTP server.
As with all classes derived from
SocketClient, you must first connect
to the server with connect before
doing anything, and finally
disconnect() after you're completely
finished interacting with the server.
Remember that the isAllowedToPost()
method is defined in NNTP.

I'd avoid using raw sockets if someone has already done this hard work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文