Bob Schneider
asked on
TelNet v Putty with vb6
I have used Putty (TelNet) to connect my race timing box with my pc in order to stream running race results as they come into my race results software. It works very well but I was trying to streamline the interface for the benefit the people doing my timing in order to avoid user error by modifying a program I found online. It works well except that it times out and so I occasionally miss some results. One other thing I have noticed is that, with the version I am using, I can FTP into the timing box and get all data. I can not do that with Putty...it seems that it is locked. I am wondering if that is an indicator that Putty locks things down more than my version and is the likely shortcoming in the one I am using. Long story short...can someone look at my code and see if they see anything amiss? If this is a bigger issue than is appropriate for this forum, I might be willing to have someone take a look at it for fair compensation.
Please note that I have no problem connecting or with any functionality except the time-out issue. Any help would be much appreciated!
Please note that I have no problem connecting or with any functionality except the time-out issue. Any help would be much appreciated!
Private Sub Form_Load()
Dim form_left As Long, form_top As Long, form_height As Long, form_width As Long
form_left = GetSetting(appname:="simptel", section:="position", Key:="Left", Default:=0)
form_top = GetSetting(appname:="simptel", section:="position", Key:="Top", Default:=0)
form_height = GetSetting(appname:="simptel", section:="position", Key:="Height", Default:=5445)
form_width = GetSetting(appname:="simptel", section:="position", Key:="Width", Default:=8895)
If (form_top = 0) Then
Me.Top = (Screen.Height / 2) - (Me.Height / 2)
Else
Me.Top = form_top
End If
If (form_left = 0) Then
Me.Left = (Screen.Width / 2) - (Me.Width / 2)
Else
Me.Left = form_left
End If
Me.Height = form_height
Me.Width = form_width
' Dim username As String, serial As Double
'
' username = GetSetting(appname:="simptel", section:="registration", Key:="user", Default:="")
' serial = GetSetting(appname:="simptel", section:="registration", Key:="code", Default:="0")
'
' If ((username <> "") And (serial <> 0)) Then
' If (func.is_valid_reg(username:=CStr(username), regcode:=Val(serial)) = True) Then
' menu_help_reg.Enabled = False
' is_regged = True
' Else
' menu_help_reg.Enabled = True
' is_regged = False
' DeleteSetting "simptel", "registration", "user"
' DeleteSetting "simptel", "registration", "code"
' End If
' Else
' menu_help_reg.Enabled = True
' is_regged = False
' End If
txtSCREEN.FontName = GetSetting(appname:="simptel", section:="fonts", Key:="fontname", Default:="Lucida Console")
txtSCREEN.FontSize = GetSetting(appname:="simptel", section:="fonts", Key:="fontsize", Default:=9)
menu_file_echo.Checked = GetSetting(appname:="simptel", section:="options", Key:="Echo", Default:=1)
menu_file_secure.Checked = GetSetting(appname:="simptel", section:="options", Key:="Secure", Default:=0)
End Sub
Private Sub Form_Resize()
If (ScaleWidth < 3000) Then
frmMAIN.Enabled = False
frmMAIN.Width = 3115
Else
frmMAIN.Enabled = True
End If
If (ScaleHeight < 1605) Then
frmMAIN.Enabled = False
frmMAIN.Height = 2290
Else
frmMAIN.Enabled = True
End If
txtSCREEN.Move 0, 0, ScaleWidth, ScaleHeight - 300
txtCMD.Move 0, txtSCREEN.Height + 25, ScaleWidth, 265
End Sub
Private Sub Form_Unload(Cancel As Integer)
menu_file_exit_Click
End Sub
Private Sub menu_edit_copy_Click()
Select Case item_got_focus
Case Is = 1
Clipboard.SetText (txtSCREEN.SelText)
Case Is = 2
Clipboard.SetText (txtCMD.Text)
Case Else
MsgBox "BUG DETECTED!"
End Select
End Sub
Private Sub menu_edit_cut_Click()
Clipboard.SetText (txtCMD.SelText)
txtCMD.SelText = ""
End Sub
Private Sub menu_edit_del_Click()
If (txtCMD.SelLength = 0) Then
txtCMD.SelLength = 1
txtCMD.SelText = ""
Else
txtCMD.SelText = ""
End If
End Sub
Private Sub menu_edit_paste_Click()
txtCMD.SetFocus
txtCMD.SelText = Clipboard.GetText
End Sub
Private Sub menu_file_clear_Click()
txtSCREEN.Text = ""
End Sub
Private Sub menu_file_connect_Click()
frmCONNECT2.Show 1
End Sub
Private Sub menu_file_disconnect_Click()
If (winsck.State <> 0) Then
winsck.Close
func.send_to_buffer ("Connection to " & winsck.RemoteHost & ":" & winsck.RemotePort & " closed.")
End If
frmMAIN.Caption = "Telnet"
End Sub
Private Sub menu_file_echo_Click()
If (menu_file_echo.Checked = False) Then
menu_file_echo.Checked = True
func.send_to_buffer ("ECHO is now ON")
Else
menu_file_echo.Checked = False
func.send_to_buffer ("ECHO is now OFF")
End If
End Sub
Public Sub menu_file_exit_Click()
'Saving form positioning setting
SaveSetting "simptel", "position", "Left", frmMAIN.Left
SaveSetting "simptel", "position", "Top", frmMAIN.Top
SaveSetting "simptel", "position", "Height", frmMAIN.Height
SaveSetting "simptel", "position", "Width", frmMAIN.Width
SaveSetting "simptel", "options", "Echo", menu_file_echo.Checked
SaveSetting "simptel", "options", "Secure", menu_file_secure.Checked
End
End Sub
Private Sub menu_file_font_Click()
With CommonDialog1
.FontName = txtSCREEN.Font
.FontSize = txtSCREEN.FontSize
.Flags = &H400 + &H3 + &H4000 + &H10000 + &H2000
.Min = 9
.Max = 16
End With
On Error GoTo ERR_FONT
CommonDialog1.ShowFont
With txtSCREEN
.Font = CommonDialog1.FontName
.FontSize = CommonDialog1.FontSize
SaveSetting "simptel", "fonts", "fontname", txtSCREEN.FontName
SaveSetting "simptel", "fonts", "fontsize", txtSCREEN.FontSize
End With
Exit Sub
ERR_FONT:
Exit Sub
End Sub
Private Sub menu_file_save_Click()
Dim logsize As Long
On Error GoTo ERR_HANDLER
Open sPath For Binary As #1
Put #1, , txtSCREEN.Text
Close #1
logsize = Len(txtSCREEN.Text)
func.send_to_buffer ("Log written to: " & sFileName)
func.send_to_buffer ("Written " & logsize & " bytes to disk")
ERR_HANDLER:
Exit Sub
End Sub
Private Sub menu_file_secure_Click()
If (menu_file_secure.Checked = True) Then
menu_file_secure.Checked = False
func.send_to_buffer ("SECURE mode is now OFF")
txtCMD.PasswordChar = ""
Else
menu_file_secure.Checked = True
func.send_to_buffer ("SECURE mode is now ON")
txtCMD.PasswordChar = " "
End If
End Sub
Private Sub tmrSaveData_Timer()
menu_file_save_Click
End Sub
Private Sub txtCMD_Change()
If (menu_file_secure.Checked = True) Then
txtCMD.PasswordChar = " "
Else
txtCMD.PasswordChar = ""
End If
End Sub
Private Sub txtCMD_GotFocus()
item_got_focus = 2
menu_edit_cut.Enabled = True
menu_edit_del.Enabled = True
End Sub
Private Sub txtCMD_KeyPress(KeyAscii As Integer)
If (KeyAscii = 13) Then
If (winsck.State = 0) Then
func.send_to_buffer ("You need to connect first!")
txtCMD.Text = ""
Else
Dim string_to_send As String
string_to_send = txtCMD.Text
If (string_to_send <> "") Then
winsck.SendData string_to_send & vbCrLf
func.send_to_buffer_norm (txtCMD.Text)
txtCMD.Text = ""
txtCMD.SetFocus
Else
func.send_to_buffer ("Nothing to send!")
txtCMD.Text = ""
txtCMD.SetFocus
End If
End If
End If
End Sub
Private Sub txtSCREEN_Change()
txtSCREEN.SelStart = Len(txtSCREEN.Text)
End Sub
Private Sub txtSCREEN_GotFocus()
item_got_focus = 1
menu_edit_cut.Enabled = False
menu_edit_del.Enabled = False
End Sub
Private Sub winsck_Close()
func.send_to_buffer ("Disconnected from: " & winsck.RemoteHost & ":" & winsck.RemotePort)
frmMAIN.Caption = "Telnet"
winsck.Close
End Sub
Private Sub winsck_Connect()
func.send_to_buffer ("Succeeded connection to: " & winsck.RemoteHost & ":" & winsck.RemotePort)
txtCMD.SetFocus
frmMAIN.Caption = "Connected to: " & winsck.RemoteHost & ":" & winsck.RemotePort
tmrSaveData.Enabled = True
End Sub
Private Sub winsck_DataArrival(ByVal bytesTotal As Long)
Dim data_received As String
winsck.GetData data_received, vbString
func.send_to_buffer_getdata (data_received)
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.