Private Sub Btn_Connect_Click() With Winsock2 If (.State <> sckClosed) Then .Close .Protocol = sckTCPProtocol .LocalPort = 1010 .Listen End With With Winsock1 If (.State <> sckClosed) Then .Close .Protocol = sckTCPProtocol .RemoteHost = "127.0.0.1" .RemotePort = 1010 .Connect End With End Sub Private Sub Btn_Disconnect_Click() If (Winsock1.State <> sckClosed) Then Winsock1.Close If (Winsock2.State <> sckClosed) Then Winsock2.Close End Sub Private Sub Btn_Envoyer_Click() If (LenB(Text1.Text) > 0) Then Winsock1.SendData Text1.Text 'Else End If End Sub Private Sub Btn_Quitter_Click() If Winsock1.State <> sckClosed Then Winsock1.Close Winsock2.Close 'Else End If Unload Me End Sub Private Sub Winsock2_ConnectionRequest(ByVal requestID As Long) If Winsock2.State <> sckClosed Then Winsock2.Close Winsock2.Accept requestID End Sub Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long) Dim strTamponInterne As String Winsock2.GetData strTamponInterne Text2.Text = strTamponInterne End Sub