VB6: Socket Server – II

Este é o código utilizado em nosso servidor:

Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If Winsock1.State sckClosed Then Winsock1.Close
Winsock1.Accept requestID
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim strdados As String
Winsock1.GetData strdados
Label1.Caption = strdados
End Sub

Private Sub Command1_Click()
Label1.Caption = strdados
End Sub

Private Sub Form_Load()
Winsock1.LocalPort = 42001
Winsock1.Listen
Label1.Caption = ""
End Sub

Private Sub Form_Unload(Cancel As Integer)
Winsock1.Close
End Sub

Anúncios