Pb avec winsock --> pas de connexion !

Résolu
floxone Messages postés 88 Date d'inscription mardi 19 avril 2005 Statut Membre Dernière intervention 10 août 2007 - 16 oct. 2005 à 00:36
floxone Messages postés 88 Date d'inscription mardi 19 avril 2005 Statut Membre Dernière intervention 10 août 2007 - 23 oct. 2005 à 15:47
Salut à tous,

Je suis débutant en dot net. Je cherche à faire un mini client ftp. Pour cela, je suis les tuto du site : ils sont géniaux... Le problème, c'est qu'après avoir implémenter une version de test, j'ai pas de connexion....

Je vous joint le code :


Public
Class Form1



Inherits System.Windows.Forms.Form


#
Region " Code généré par le Concepteur Windows Form "



Public
Sub
New()



MyBase.New()



'Cet appel est requis par le Concepteur Windows Form.


InitializeComponent()



'Ajoutez une initialisation quelconque après l'appel InitializeComponent()



End
Sub



'La méthode substituée Dispose du formulaire pour nettoyer la liste des composants.



Protected
Overloads
Overrides
Sub Dispose(
ByVal disposing
As
Boolean)



If disposing
Then



If
Not (components
Is
Nothing)
Then


components.Dispose()



End
If



End
If



MyBase.Dispose(disposing)



End
Sub



'Requis par le Concepteur Windows Form



Private components
As System.ComponentModel.IContainer



'REMARQUE : la procédure suivante est requise par le Concepteur Windows Form



'Elle peut être modifiée en utilisant le Concepteur Windows Form.



'Ne la modifiez pas en utilisant l'éditeur de code.



Friend
WithEvents command1
As System.Windows.Forms.Button



Friend
WithEvents Winsock
As AxMSWinsockLib.AxWinsock



Friend
WithEvents Wck
As AxMSWinsockLib.AxWinsock


<System.Diagnostics.DebuggerStepThrough()>
Private
Sub InitializeComponent()



Dim resources
As System.Resources.ResourceManager =
New System.Resources.ResourceManager(
GetType(Form1))



Me.command1 =
New System.Windows.Forms.Button()



Me.Winsock =
New AxMSWinsockLib.AxWinsock()



Me.Wck =
New AxMSWinsockLib.AxWinsock()



CType(
Me.Winsock, System.ComponentModel.ISupportInitialize).BeginInit()



CType(
Me.Wck, System.ComponentModel.ISupportInitialize).BeginInit()



Me.SuspendLayout()



'



'command1



'



Me.command1.Location =
New System.Drawing.Point(112, 112)



Me.command1.Name = "command1"



Me.command1.TabIndex = 1



Me.command1.Text = "BTconnec "



'



'Winsock



'



Me.Winsock.Enabled =
True



Me.Winsock.Location =
New System.Drawing.Point(88, 48)



Me.Winsock.Name = "Winsock"



Me.Winsock.OcxState =
CType(resources.GetObject("Winsock.OcxState"), System.Windows.Forms.AxHost.State)



Me.Winsock.Size =
New System.Drawing.Size(28, 28)



Me.Winsock.TabIndex = 2



'



'Wck



'



Me.Wck.Enabled =
True



Me.Wck.Location =
New System.Drawing.Point(168, 48)



Me.Wck.Name = "Wck"



Me.Wck.OcxState =
CType(resources.GetObject("Wck.OcxState"), System.Windows.Forms.AxHost.State)



Me.Wck.Size =
New System.Drawing.Size(28, 28)



Me.Wck.TabIndex = 3



'



'Form1



'



Me.AutoScaleBaseSize =
New System.Drawing.Size(5, 13)



Me.ClientSize =
New System.Drawing.Size(292, 266)



Me.Controls.AddRange(
New System.Windows.Forms.Control() {
Me.Wck,
Me.Winsock,
Me.command1})



Me.Name = "Form1"



Me.Text = "Form1"



CType(
Me.Winsock, System.ComponentModel.ISupportInitialize).EndInit()



CType(
Me.Wck, System.ComponentModel.ISupportInitialize).EndInit()



Me.ResumeLayout(
False)



End
Sub


#
End
Region






Private
Sub Form1_Load(
ByVal sender
As System.Object,
ByVal e
As System.EventArgs)
Handles
MyBase.Load


Winsock.LocalPort = 5000
'rq : la propriété aurait pu être défini directement


Winsock.Listen()



End
Sub



Private
Sub command1_Click(
ByVal sender
As System.Object,
ByVal e
As System.EventArgs)
Handles command1.Click


Wck.Close()


Wck.Connect("127.0.0.1", 5000)



End
Sub



Private
Sub Winsock_ConnectionRequest(
ByVal requestID
As
Long)


Winsock.Accept(requestID)



End
Sub



Private
Sub Wck_Connect()


MsgBox("Trouvé")



End
Sub


End
Class

J'ai placé des points d'arrêt. Je ne rentre jamais ds le Winsock_ConnectionRequest et donc, jamais dans le Wck_Connect. Vous aurez donc compris que la MsgBox n'apparait pas.

Je suis sur un routeur, mais puisque je prend localhost, je pense pas que cela pose probleme ! J'ai deconnecter norton et pare feu windows...

Si quelqu'un voit un problème, cela me permettrait d'avancer ! Il commence à ce faire tard et je ne trouve vraiment pas...

Merci de votre aide.

Flo.

1 réponse

floxone Messages postés 88 Date d'inscription mardi 19 avril 2005 Statut Membre Dernière intervention 10 août 2007
23 oct. 2005 à 15:47
C'est bon, j'ai trouvé : il faut passer en mode passif (PASV) et ouvrir une deuxième connexion pour recevoir les données.
3
Rejoignez-nous