472,142 Members | 1,046 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,142 software developers and data experts.

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
2 49753
"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
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.