Need help with Winsocket control in Microsoft Access Database form.

I'm trying to create a telnet session within my microsoft access form. I included the microsoft winsocket control and some text boxes to place the recieved data. The problem I'm having is I recieve data but it is all scrambled like yt%yy and it doesn't take any of my data I'm entering. The current telnet software I'm using is using VT101 emulation if that might have something to do with the scrambled info, but I dont want to use this software and Access. I would like to keep it all in one application if possible. I just need some help where I might be going wrong or any other idea's. Here is a sample of the code I'm using.

Option Explicit
Const EchoPort = 23

Private Sub cmdConnect_Click()
Dim temp As String
temp = InputBox$("Enter a server name...", _
"Connect to the Echo Service", Winsock1.RemoteHost)
If temp <> "" Then
If Winsock1.State <> sckClosed Then Winsock1.Close
Winsock1.RemoteHost = temp
Winsock1.RemotePort = EchoPort
Winsock1.LocalPort = 0
Winsock1.Connect
End If
End Sub

Private Sub cmdDisconnect_Click()
If Winsock1.State <> sckClosed Then Winsock1.Close
cmdConnect.Enabled = True
cmdConnect.SetFocus
cmdDisconnect.Enabled = False

End Sub

Private Sub cmdEcho_Click()
Text1.SetFocus
Winsock1.SendData Text1.Text
Text2.SetFocus
End Sub

Private Sub Winsock1_Close()
If Winsock1.State <> 0 Then Winsock1.Close
End Sub

Private Sub Winsock1_Connect()
Text2.SetFocus
cmdConnect.Enabled = False
cmdEcho.Enabled = True
cmdDisconnect.Enabled = True
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)

Dim temp As String
temp = String(bytesTotal, "*")
Winsock1.GetData temp, vbString, bytesTotal
Text2.SetFocus
Text2.Text = temp
cmdEcho.Enabled = True
End Sub

Private Sub Winsock1_Error(ByVal Number As Integer, _
Description As String, _
ByVal Scode As Long, _
ByVal Source As String, _
ByVal HelpFile As String, _
ByVal HelpContext As Long, _
CancelDisplay As Boolean)
MsgBox "Error: " & Number & vbTab & Description, vbOKOnly, _
"Winsock Control 1 Error"
CancelDisplay = True
End Sub





Answer this question

Need help with Winsocket control in Microsoft Access Database form.

  • CelestialNavigator

    I'm trying to connect to a Unix AIX system. Normally when I connect through our usuall telnet software the first bit of information sent back to the program looks like this...

    AIX Version 5
    (C) copyrights by IBM and by others 1982, 2005.
    login:

    Any help with what direction I might need to go next.



  • Eagleguy125

    Just from a quick peek at the "scrambled" data you say you're receiving from the telnet site, it looks like you're decoding the data improperly. The "y" which shows up repeatedly in your data string is 0xFF in the ASCII table, and it usually denotes the end of a data field.

    Without knowing what application you're accessing via telnet, it's impossible to determine how to decode the data.



  • Need help with Winsocket control in Microsoft Access Database form.