By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,107 Members | 1,607 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,107 IT Pros & Developers. It's quick & easy.

NNTP Client

P: n/a
BiT
Hi

i'm trying to code simple nntp client with vb.net and sockets client class

the problem is the machine keep stuck (probbley beacuse it ain't gettin`
data from the server) after the user name sent to the server when it's try
to read the stream, i checked it out in telnet and server send stream after
i send the user name any idea why it's not workin`?

here's the code:

Imports System.Net.Sockets
Imports System.Text

Public Class Form1

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load

Dim tcpClient As New System.Net.Sockets.TcpClient()

Dim returndata As String

Dim bytes(tcpClient.ReceiveBufferSize) As Byte

Dim sendBytes As [Byte]()

tcpClient.Connect("news.giganews.com", 119)

Dim networkStream As NetworkStream = tcpClient.GetStream()

' Read the NetworkStream into a byte buffer.

networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))

' Output the data received from the host to the console.

returndata = Encoding.ASCII.GetString(bytes)

textbox1.text = textbox1.text & Returndata

' Send user name to the server

sendBytes = Encoding.ASCII.GetBytes("AUTHINFO USER ****")

networkStream.Write(sendBytes, 0, sendBytes.Length)

' Read the NetworkStream into a byte buffer.

networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))

returndata = Encoding.ASCII.GetString(bytes)

TextBox1.Text = TextBox1.Text & Returndata

' Send Paswod to the server

sendBytes = Encoding.ASCII.GetBytes("AUTHINFO PASS ****")

networkStream.Write(sendBytes, 0, sendBytes.Length)

' Read the NetworkStream into a byte buffer.

networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))

returndata = Encoding.ASCII.GetString(bytes)

TextBox1.Text = TextBox1.Text & returndata

End Sub

End Class

May 25 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"BiT" <sh********@walla.comwrote in
news:Ka******************************@giganews.com :
Hi

i'm trying to code simple nntp client with vb.net and sockets client
class

the problem is the machine keep stuck (probbley beacuse it ain't
gettin` data from the server) after the user name sent to the server
when it's try to read the stream, i checked it out in telnet and
server send stream after i send the user name any idea why it's not
workin`?

here's the code:

Have you looked at the Indy Socket class? I think it has a NNTP classes
prebuilt. Otherwise nSoftware's IPWorks package has a good NNTP client.
Also take a look at TCPTrace from PocketSoap. It's a free application
allowing you to see the TCP stream. AFAIK, you're supposed to get a return
code with every command you issue - are you getting those codes back? Maybe
you didn't send the end of line terminator so the server hasn't processed
the command?
May 25 '07 #2

P: n/a
BiT
I think i didn't send the end of line terminator, how do i do it?

thanks

"Spam Catcher" <sp**********@rogers.comwrote in message
news:Xn**********************************@127.0.0. 1...
"BiT" <sh********@walla.comwrote in
news:Ka******************************@giganews.com :
>Hi

i'm trying to code simple nntp client with vb.net and sockets client
class

the problem is the machine keep stuck (probbley beacuse it ain't
gettin` data from the server) after the user name sent to the server
when it's try to read the stream, i checked it out in telnet and
server send stream after i send the user name any idea why it's not
workin`?

here's the code:


Have you looked at the Indy Socket class? I think it has a NNTP classes
prebuilt. Otherwise nSoftware's IPWorks package has a good NNTP client.
Also take a look at TCPTrace from PocketSoap. It's a free application
allowing you to see the TCP stream. AFAIK, you're supposed to get a return
code with every command you issue - are you getting those codes back?
Maybe
you didn't send the end of line terminator so the server hasn't processed
the command?
May 25 '07 #3

P: n/a
"BiT" <sh********@walla.comwrote in
news:Gq******************************@giganews.com :
I think i didn't send the end of line terminator, how do i do it?
You could try sending VBCRLF (return character).
May 25 '07 #4

P: n/a
BiT
Works Great

thanks

"Spam Catcher" <sp**********@rogers.comwrote in message
news:Xn*********************************@127.0.0.1 ...
"BiT" <sh********@walla.comwrote in
news:Gq******************************@giganews.com :
>I think i didn't send the end of line terminator, how do i do it?

You could try sending VBCRLF (return character).
May 25 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.