Je connaissais ce lien, merci quand même
.
Voici un code que j'ai trouvé sur le net mais il n'intègre pas la réception de messages proprement dite, il ne fait que la connection au serveur et l'identification.
Sur cet exemple, pourriez-vous me montrer où et comment intégrer la réception ?
Merci d'avance
Private WithEvents evt As Winsock
Private nextSend As Boolean
Private answer As String
Private nbrecept As Long
Private Sub btnConnect_Click()
Dim tmp As String
Set evt = ws
nbrecept = 0
ws.Connect txtServer.Text, 110
While ws.State <> sckConnected
DoEvents
Wend
'Attente du message de bienvenue
nextSend = False
While nextSend = False
DoEvents
Wend
nextSend = False
ws.SendData "USER " & txtLogin.Text & vbCrLf
While nextSend = False
DoEvents
Wend
nextSend = False
ws.SendData "PASS " & txtPassword.Text & vbCrLf
While nextSend = False
DoEvents
Wend
If InStr(1, answer, "OK") > 0 Then
lblMessage.Caption = "Vous êtes connecté"
Else
'lblMessage.Caption = "Login/mot de passe incorrect"
End If
End Sub
Private Sub btnDisconnect_Click()
ws.Close
End Sub
Private Sub evt_ConnectionRequest(ByVal requestID As Long)
rtxtLog.Text = rtxtLog.Text & vbCrLf & "Demande de connexion au serveur"
End Sub
Private Sub evt_DataArrival(ByVal bytesTotal As Long)
Dim tmp As String
If ws.State = sckClosed Or ws.State = sckClosing Then Exit Sub
ws.GetData tmp, vbString, bytesTotal
rtxtLog.Text = rtxtLog.Text & Chr(13) & tmp
rtxtLog.Refresh
nextSend = True
End Sub
Private Sub evt_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)
MsgBox Number & " : " & Description
End Sub