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