"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