webseb02
Messages postés4Date d'inscriptionlundi 23 décembre 2002StatutMembreDernière intervention16 avril 2003
-
16 avril 2003 à 23:32
BasicInstinct
Messages postés1470Date d'inscriptionmardi 5 février 2002StatutMembreDernière intervention20 octobre 2014
-
17 avril 2003 à 09:35
Je n'arrive pas à faire accepter plusieurs connection a mon serveur, g tt essayé rien ne marche
J'ai par exemple 2 controle winsock et un bouton connect
- listen --> local port 660
- dial --> index=0, remote host=127.0.0.1 remote port= 660
je voudrai que lorsque une connexion est accepté afficher le messge xx est connecté
Voici la source :
Dim nb As Integer
Private Sub Connect_Click()
dial(0).connect "127.0.0.1", 660
End Sub
Private Sub dial_Connect(Index As Integer)
MsgBox nb + " s'est connecté"
End Sub
Private Sub Form_Load()
nb = 0
listen.LocalPort = 660
listen.listen
End Sub
Private Sub listen_ConnectionRequest(ByVal requestID As Long)
nb = nb + 1
Load dial(nb)
dial(nb).Accept requestID
End Sub
Quand je lance g rien a l'affichage, le programme entre bien ds la procédure listen_ConnectionRequest mais ne rentre jamais dans dial_Connect(Index As Integer)
Est ce que quelqu'un pourrai m'apporter une aide précieuse ?
BasicInstinct
Messages postés1470Date d'inscriptionmardi 5 février 2002StatutMembreDernière intervention20 octobre 201412 17 avril 2003 à 09:35
'lut
'voilou un exemple :))
Public NickName As String
Public intmax As Integer
Public IsServeur As Boolean
Private Sub Command1_Click()
IsServeur = False
NickName = "Client"
Winsock1(0).Close
Winsock1(0).Connect "127.0.0.1", 30002
End Sub
Private Sub Command2_Click()
IsServeur = True
NickName = "Serveur"
Winsock1(0).LocalPort = 30002
Winsock1(0).Listen
lstChat.AddItem "Serveur online"
End Sub
Private Sub txtPhrase_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And Trim(txtPhrase) <> "" Then
If IsServeur Then
For I = 1 To intmax
If Winsock1(I).State = sckConnected Then
Winsock1(I).SendData NickName & " : " & txtPhrase
End If
Next
lstChat.AddItem txtPhrase
Else
Winsock1(0).SendData NickName & " : " & txtPhrase
End If
txtPhrase = ""
End If
End Sub
Private Sub Winsock1_Connect(Index As Integer)
lstChat.AddItem "Connection etablie"
End Sub
Private Sub Winsock1_ConnectionRequest(Index As Integer, ByVal requestID As Long)
If Index = 0 Then
intmax = intmax + 1
Load Winsock1(intmax)
Winsock1(intmax).LocalPort = 30002
Winsock1(intmax).Accept requestID
lstChat.AddItem "Client" & intmax & " connecté"
End If
End Sub
Private Sub Winsock1_DataArrival(Index As Integer, ByVal bytesTotal As Long)
Dim tmp As String
Winsock1(Index).GetData tmp
If IsServeur Then
For I = 1 To intmax
If Winsock1(I).State = sckConnected Then
Winsock1(I).SendData tmp
End If
Next
End If
lstChat.AddItem tmp
End Sub