Voila un petit ecouteur de port qui permet de selectionner un port pour ecoute , et ensuite d'attendre une connexion, lorsque la connexion est etablit on peut envoyer du texte, et on peut voir les donner envoyer par le remote side .
LE ZIPPPPPP
' Ajouter 2 bouton command1 et command2
' un objet winsock (winsock1)
' 3 label (de label1,label2, label3)
' 5 text box (Text1 -> Text5)
' un timer (Timer1)
Dim c As Boolean
Private Sub Command1_Click()
Winsock1.Close
Winsock1.LocalPort = Text1.Text
Winsock1.Listen
Label3.Caption = "ecoute"
End Sub
Private Sub Command2_Click()
Dim txt
txt = Text2.Text
Winsock1.SendData txt
End Sub
Private Sub Timer1_Timer()
Winsock1.Close: Winsock1.Listen: c = False
End Sub
Private Sub Winsock1_Close()
Label3.Caption = "ecoute"
If c = False Then c = True
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
Winsock1.Close
Winsock1.Accept requestID
Winsock1.SendData Chr(13) "OK"
Label3.Caption = "COnnecté"
Text4.Text = Winsock1.RemoteHostIP
Text5.Text = Winsock1.RemoteHost
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim dat As String
Winsock1.GetData dat
Text3.Text = Text3.Text dat
End Sub
' Pour plus d'info voir le zip
|