467,143 Members | 1,236 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,143 developers. It's quick & easy.

Simple Telnet client using Winsock in VB6

Dan
I'm writing a simplistic telnet client in VB6 and I've run into a small
snag. The program has a textbox to write in the string to be sent using
..SendData and has another textbox that displays what that server sends.
When I first connect to the server (in this case, my university's smtp
server), I get a response that the server acknowledges my connection. When
I type something into the textbox and send it, however, I get no response
whatsoever. I tested the _DataArrival event subroutine and it's not even
firing (except when I first connect). My guess is that Winsock's .SendData
method does not send the data in the appropriate format for the telnet
server to interpret, but I do not even begin to know how to figure that out.
The source is pasted below. It consists of two textboxes (sending data and
reviewing received data), three buttons (connect, send, exit), and the
Winsock control (named telnet). If the code looks fimiliar, that's because
it's adapted from MSDN's example library. Any help would be appreciated.

Private Sub Form_Load()
telnet.RemoteHost = "mail.rpi.edu"
telnet.RemotePort = 110
End Sub

Private Sub cmdConnect_Click()
telnet.Connect
cmdConnect.Enabled = False
End Sub

Private Sub telnet_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
telnet.GetData strData
txtOutput.Text = txtOutput.Text & strData
End Sub

Private Sub cmdSendData_Click()
If telnet.State = sckConnected Then
telnet.SendData txtSend.Text
End If
End Sub

Private Sub cmdEnd_Click()
telnet.Close
End
End Sub
Jul 17 '05 #1
  • viewed: 48502
Share:
2 Replies
"Dan" <a@a.com> wrote in message news:<d7*****************@twister.nyroc.rr.com>...
I'm writing a simplistic telnet client in VB6 and I've run into a small
snag. The program has a textbox to write in the string to be sent using
.SendData and has another textbox that displays what that server sends.
When I first connect to the server (in this case, my university's smtp
server), I get a response that the server acknowledges my connection. When
I type something into the textbox and send it, however, I get no response
whatsoever. I tested the _DataArrival event subroutine and it's not even
firing (except when I first connect). My guess is that Winsock's .SendData
method does not send the data in the appropriate format for the telnet
server to interpret, but I do not even begin to know how to figure that out.
The source is pasted below. It consists of two textboxes (sending data and
reviewing received data), three buttons (connect, send, exit), and the
Winsock control (named telnet). If the code looks fimiliar, that's because
it's adapted from MSDN's example library. Any help would be appreciated.

Private Sub Form_Load()
telnet.RemoteHost = "mail.rpi.edu"
telnet.RemotePort = 110
End Sub

Private Sub cmdConnect_Click()
telnet.Connect
cmdConnect.Enabled = False
End Sub

Private Sub telnet_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
telnet.GetData strData
txtOutput.Text = txtOutput.Text & strData
End Sub

Private Sub cmdSendData_Click()
If telnet.State = sckConnected Then
telnet.SendData txtSend.Text
most telnet-based applications (including the standard mail protocol
on port 110) require that transmissions be terminated with CR/LF
pairs; without that the server assumes more data is coming and waits.
try this:
telnet.SendData txtSend.Text & vbCRLF

If that fails you'll need to find out what protocol the specific
server is using.
End If
End Sub

Private Sub cmdEnd_Click()
telnet.Close
End
don't use END. That is an abrupt, drastic termination of your app and
is NEVER needed. VB apps end normally when all forms are unloaded and
no code is running. In this case all you need is "Unload Me".
End Sub

Jul 17 '05 #2
Dan
"Bob Butler" <bu*******@earthlink.net> wrote in message
news:fa*************************@posting.google.co m...
"Dan" <a@a.com> wrote in message

news:<d7*****************@twister.nyroc.rr.com>...
I'm writing a simplistic telnet client in VB6 and I've run into a small
snag. The program has a textbox to write in the string to be sent using
.SendData and has another textbox that displays what that server sends.
When I first connect to the server (in this case, my university's smtp
server), I get a response that the server acknowledges my connection. When I type something into the textbox and send it, however, I get no response whatsoever. I tested the _DataArrival event subroutine and it's not even firing (except when I first connect). My guess is that Winsock's ..SendData method does not send the data in the appropriate format for the telnet
server to interpret, but I do not even begin to know how to figure that out. The source is pasted below. It consists of two textboxes (sending data and reviewing received data), three buttons (connect, send, exit), and the
Winsock control (named telnet). If the code looks fimiliar, that's because it's adapted from MSDN's example library. Any help would be appreciated.
Private Sub Form_Load()
telnet.RemoteHost = "mail.rpi.edu"
telnet.RemotePort = 110
End Sub

Private Sub cmdConnect_Click()
telnet.Connect
cmdConnect.Enabled = False
End Sub

Private Sub telnet_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
telnet.GetData strData
txtOutput.Text = txtOutput.Text & strData
End Sub

Private Sub cmdSendData_Click()
If telnet.State = sckConnected Then
telnet.SendData txtSend.Text


most telnet-based applications (including the standard mail protocol
on port 110) require that transmissions be terminated with CR/LF
pairs; without that the server assumes more data is coming and waits.
try this:
telnet.SendData txtSend.Text & vbCRLF

If that fails you'll need to find out what protocol the specific
server is using.
End If
End Sub

Private Sub cmdEnd_Click()
telnet.Close
End


don't use END. That is an abrupt, drastic termination of your app and
is NEVER needed. VB apps end normally when all forms are unloaded and
no code is running. In this case all you need is "Unload Me".
End Sub


Thank you, that was exactly it. And thanks for the advice regarding END.
That's definitely a fossil of my QBasic days.

-Dan
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Donnal Walter | last post: by
4 posts views Thread by Tim Tyler | last post: by
4 posts views Thread by Enos Meroka | last post: by
5 posts views Thread by Greg Martz | last post: by
1 post views Thread by Arif | last post: by
reply views Thread by Link | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.