Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: The_Bug en 31 Agosto 2009, 21:18 pm



Título: Conexion Winsock
Publicado por: The_Bug en 31 Agosto 2009, 21:18 pm
hola...
tengo un problema on winsock
toy hacendo una aplicaccion "cliente" con winsock y VB 6.0
ya hice varias aplicacciones similares (funcionales) con fines didacticos...
esos programas q establesen conexión para enviar un texto acsii al servidor  resivir su respuesta y visualisarla...

el problema es q cuando nesesito realmente hacer una aplicaccion con winsock fallan 2 eventos; puede hacer todo menos saber si el servidor esta enviando informacion y tampoco si el servidor serro la conexión,lo q me inutilisa la aplicacion...

si conecto a google y envio algo el servidor no me contesta como se supone
pero si intento estableser una conexión con mi propio pc si puedo ver la nformacion q envia la aplicaccion servidor pero no puedo saber si la aplicaccion servidor serro la conexión

miren la foto

(http://www.arribalafoto.com/public/82009/Dibuafsasfasfafjo.JPG)

puede verse q establesco conexión con una aplicaccion servidor en mi propio pc
pero no funciona del mismo modo en un servidor remoto
ademas no puedo saber cuando la aplicaccion servidor finaliso conexión
osea si sierro el NC la aplicacion VB no me lo hace saber (tampoco me lo hace saber cuando se trata de servidores remotos)

les paso el codigo fuente  solo para q me aseguren q el error no esta en el codigo

asd


Private Sub Command1_Click()
Text3.SelStart = Len(Text3.Text)
Text3.Text = Text3.Text & vbCrLf & "Cliente>Conectando..." & vbCrLf
Text3.SelStart = Len(Text3.Text)

Winsock1.Close
Winsock1.RemoteHost = Text1.Text
If IsNumeric(Text4.Text) Then
Winsock1.RemotePort = Text4.Text
Else
Winsock1.RemotePort = 80
End If
Winsock1.Connect
Label6.Caption = Winsock1.LocalIP
Label4.Caption = ""
End Sub


Private Sub Command2_Click()
Winsock1.Close
Text3.SelStart = Len(Text3.Text)
Text3.Text = Text3.Text & vbCrLf & "Cliente>Desconectado" & vbCrLf
Text3.SelStart = Len(Text3.Text)
End Sub




Private Sub Command3_Click()
Winsock1.SendData (Text2.Text)
Text3.SelStart = Len(Text3.Text)
Text3.Text = Text3.Text & vbCrLf & "Cliente>" & vbCrLf & "<<data>>" & vbCrLf & Text2.Text & vbCrLf & "<</data>>" & vbCrLf
Text3.SelStart = Len(Text3.Text)
End Sub

Private Sub winsock1_DataArrival(ByVal dat As Long)
Dim Data As String
Winsock1.GetData Data

Text3.SelStart = Len(Text3.Text)
Text3.Text = Text3.Text & vbCrLf & "Servidor>" & vbCrLf & "<<data>>" & vbCrLf & Data & vbCrLf & "<</data>>" & vbCrLf
Text3.SelStart = Len(Text3.Text)
End Sub


Private Sub Winsock1_Close()



Winsock1.Close



Text3.SelStart = Len(Text3.Text)
Text3.Text = Text3.Text & vbCrLf & "Servidor>Desconectado" & vbCrLf
Text3.SelStart = Len(Text3.Text)



Label6.Caption = Winsock1.LocalIP
Label4.Caption = " "
Label2.Caption = "Desconectado"
End Sub


Private Sub Winsock1_Connect()
Text3.SelStart = Len(Text3.Text)
Text3.Text = Text3.Text & vbCrLf & "Servidor>Conectado" & vbCrLf
Text3.SelStart = Len(Text3.Text)
Label4.Caption = Winsock1.RemoteHostIP
Label2.Caption = "Conectado"
End Sub


Private Sub Text4_Change()
If IsNumeric(Text4.Text) Then
Else
Text4.Text = 0
End If
End Sub



uso windowns xp servise pack 2
pedirle ayuda a ustedes es mi ultimo recurso para poder terminar el coso
si nesesitan mas informacion pidanmela
chau
gracias


Título: Re: Conexion Winsock
Publicado por: The_Bug en 4 Septiembre 2009, 01:16 am
el codigo esta mal??¿??? :huh: :huh: :huh: :huh:


Título: Re: Conexion Winsock
Publicado por: The_Bug en 4 Septiembre 2009, 03:19 am
problema solucionado...

solo hizo falta reinstalar el SO :(


Título: Re: Conexion Winsock
Publicado por: The_Bug en 4 Septiembre 2009, 03:40 am
na joda
me faltaba enviar un salto de linea despues decada paquete enviado el pc remoto :P