Probleme avec winsock(senddata)

cs_phpman Messages postés 38 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 2 décembre 2003 - 18 déc. 2002 à 13:23
buzydoudou Messages postés 50 Date d'inscription mardi 24 août 2004 Statut Membre Dernière intervention 28 avril 2005 - 22 avril 2005 à 21:26
Bonjour,
J'essai de faire une mini appli avec winsock et j'ai probleme avec SendData j'ai ecrit ça:
Winsock1.SendData "phpman"
et il me dit: erreur 4006 .....
Donc si vous avez une solution....
Merci d'avance.

7 réponses

BasicInstinct Messages postés 1470 Date d'inscription mardi 5 février 2002 Statut Membre Dernière intervention 20 octobre 2014 12
18 déc. 2002 à 15:27
verifie l'etat de ta connection avant:
winsock1.State. A mon avis tu n'est pas connecté.
:clown) BasicInstinct :clown)
0
cs_phpman Messages postés 38 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 2 décembre 2003 1
18 déc. 2002 à 19:10
Bonjou,Oui c'est bien la connection et quand je regarde winsock1.State et il m'indique 8 ce qui veut dire: connexion en cours de fermeture pas l'homologue
peut être que c'est le code du serveur qui ne va pas?
je suis debutant alors pour l'instant ça m'est difficile...
Si quelqu'un peut m'aider...
Merci.
0
BasicInstinct Messages postés 1470 Date d'inscription mardi 5 février 2002 Statut Membre Dernière intervention 20 octobre 2014 12
19 déc. 2002 à 11:56
voila 1 pseudo chat multi user reduit au strict minimum
t'as besoin de 2 commandbutton:
command1 pour lancer le client
command2 pour le serveur

1textbox txtPhrase pour ecrire les messages a envoyer
1 listbox lstChat qui sert de zone de reception

Si tu as des questions....

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


:clown) BasicInstinct :clown)
0
cs_phpman Messages postés 38 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 2 décembre 2003 1
20 déc. 2002 à 22:34
Je te remerci beaucoup pour cette source !!
mais je voudrai savoir a quoi sert:

Winsock1(I)
Winsock1(Index)
Winsock1(0)

Encore une foi merci...
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
BasicInstinct Messages postés 1470 Date d'inscription mardi 5 février 2002 Statut Membre Dernière intervention 20 octobre 2014 12
23 déc. 2002 à 11:01
en fait, ca indexe tes winsock (utilisation multi clients)

par exemple (dans le code que je t'ai filé)

winsock(0) c'est le winsock de demande de connection
winsock(1) correspond au premier client
winsock(2) correspond au deuxieme client
.....

:clown) BasicInstinct
0
brenault Messages postés 1 Date d'inscription mercredi 3 novembre 2004 Statut Membre Dernière intervention 3 novembre 2004
3 nov. 2004 à 14:17
Bonjour,

j'ai moi aussi le même problème, je n'arrive pas à utiliser les Winsock, car ils sont vide.

Merci d'avance
0
buzydoudou Messages postés 50 Date d'inscription mardi 24 août 2004 Statut Membre Dernière intervention 28 avril 2005
22 avril 2005 à 21:26
Je ne connaissais pas les "Winsock vides" !! Que veux-tu dire par là ?!
0
Rejoignez-nous