Private Sub Command1_Click()
If Len(Text4.Text) > 0 Then
Winsock1.SendData Text4.Text
Text3.Text = Text3.Text & "<Client>" & Text4.Text & vbCrLf
Text3.SelStart = Len(Text3.Text)
Text4.Text = vbNullString
Label5.Caption = "Invio di " & LenB(Text4.Text) & "Bytes"
End If
End Sub
Private Sub Command2_Click()
Static Stat As Boolean
If Stat = False Then
If Len(Text1.Text) > 0 And Len(Text2.Text) > 0 Then
Winsock1.Connect Text1, Val(Text2.Text)
Command2.Caption = "Disconnetti"
Stat = True
Label5.Caption = "Connessione in corso"
Else
MsgBox "Dati mancanti", vbExclamation
End If
Else
Winsock1.Close
Stat = False
Label5.Caption = "Chisura in corso"
Command2.Caption = Connetti
End If
End Sub
Private Sub Winsock1_Close()
Winsock1.Close
Label5.Caption = "Disconnesso"
End Sub
Private Sub Winsock1_Connect()
Label5.Caption = "Connesso"
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim Data As String
Winsock1.GetData Data
Label5.Caption = "In arrivo " & bytesTotal & "Bytes"
Text3.Text = Text3.Text & "<Remoto>" & Data & vbCrLf
Text3.SelStart = Len(Text3.Text)
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)
Winsock1.Close
MsgBox "Errore TCP " & Number & vbCrLf & Description
Label5.Caption = "Errore TCP " & Number
End Sub
Private Sub Winsock1_SendComplete()
Label5.Caption = "Dati inviati"
End Sub