Hola a todos, este es mi primer post... xD
Bueno, estaba haciendo un troyano en VB6 con Winsock 6.0, (todavía no he hecho el server)
Al poner el puerto y de host google, pero tira el error ¬¬
No sé de qué se trata, aquí está el código:
'CONEXIÓN'
Private Sub Command2_Click()
Winsock1.RemoteHost = Text3.Text
Winsock1.RemotePort = Text4.Text
Winsock1.Close
Winsock1.Connect
End Sub
Private Sub Winsock1_Connect()
Text1.Text = Text1.Text & "*** Conexion establecida." & vbCrLf
Text1.SelStart = Len(Text1.Text)
End Sub
'DESCONEXIÓN POR ERROR'
Private Sub Winsock1_Close()
'cierra la conexion
Winsock1.Close
'mensaje en la ventana
Text1.SelStart = Len(Text1.Text)
Text1.Text = Text1.Text & "*** Conexion cerrada por el servidor." & vbCrLf
Text1.SelStart = Len(Text1.Text)
End Sub
'DESCONEXIÓN DESDE CLIENTE'
Private Sub Command3_Click()
Winsock1.Close
Text1.Text = Text1.Text & "*** Conexion cerrada por el usuario." & vbCrLf
'desplazamos el scroll
Text1.SelStart = Len(Text1.Text)
End Sub
'ENVIAR'
Private Sub Command1_Click()
'enviamos el contenido de Text2
Winsock1.SendData Text2.Text & vbCrLf
'apuntamos al final del contenido del TextBox e
'insertamos los nuevos datos obtenidos
Text1.SelStart = Len(Text1.Text)
Text1.Text = Text1.Text & "Cliente >" & Text2.Text & vbCrLf
Text1.SelStart = Len(Text1.Text)
Text2.Text = ""
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim Buffer As String 'variable para guardar los datos
'obtenemos los datos y los guardamos en una variable
Winsock1.GetData Buffer
'apuntamos al final del contenido del TextBox e
'insertamos los nuevos datos obtenidos
Text1.SelStart = Len(Text1.Text) 'coloca el cursor al final del contenido
Text1.Text = Text1.Text & "Servidor >" & Buffer 'mostramos los datos
Text1.SelStart = Len(Text1.Text) 'coloca el cursor al final del contenido
End Sub
'ERRORES
Private Sub Winsock1_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)
'cerramos la conexion
Winsock1.Close
'mostramos informacion sobre el error
MsgBox "Error numero " & Number & ": " & Description, vbCritical
End Sub
No sé qué ocurre, alguien sabe algo?
Gracias
Coloca ip y puerto por codigo en lugar de cogerlo por un texbox y vuelve a probar
Winsock1.RemoteHost = google.es
Winsock1.RemotePort = 80
Cita de: Nanoc en 24 Febrero 2010, 01:42 AM
Coloca ip y puerto por codigo en lugar de cogerlo por un texbox y vuelve a probar
Winsock1.RemoteHost = google.es
Winsock1.RemotePort = 80
Por seguridad la DNS es entre comillas, el puerto por mi parte me da igual.
Winsock1.RemoteHost = "www.google.com.mx"
pero prueba con este corregí algunas cosillas y te las comente.
'CONEXIÓN'
Private Sub Command2_Click()
' antes de cambiar el remotehost y el remoteport hay que cerrar o verificar que este cerrado el socket, o causaria un error lo mas seguro.
Winsock1.Close
Winsock1.RemoteHost = Text3.Text
Winsock1.RemotePort = Val(Text4.Text)
Winsock1.Connect
End Sub
Private Sub Winsock1_Connect()
Text1.Text = Text1.Text & "*** Conexion establecida." & vbCrLf
Text1.SelStart = Len(Text1.Text)
End Sub
'DESCONEXIÓN POR ERROR'
Private Sub Winsock1_Close()
'cierra la conexion
Winsock1.Close
'mensaje en la ventana
Text1.SelStart = Len(Text1.Text)
Text1.Text = Text1.Text & "*** Conexion cerrada por el servidor." & vbCrLf
Text1.SelStart = Len(Text1.Text)
End Sub
'DESCONEXIÓN DESDE CLIENTE'
Private Sub Command3_Click()
Winsock1.Close
Text1.Text = Text1.Text & "*** Conexion cerrada por el usuario." & vbCrLf
'desplazamos el scroll
Text1.SelStart = Len(Text1.Text)
End Sub
'ENVIAR'
Private Sub Command1_Click()
' 7 = socket conectado.
If Winsock1.State = 7 Then ' hay que verificar que exista una conexion actual o causa un error.
'enviamos el contenido de Text2
Winsock1.SendData Text2.Text & vbCrLf
'apuntamos al final del contenido del TextBox e
'insertamos los nuevos datos obtenidos
Text1.SelStart = Len(Text1.Text)
Text1.Text = Text1.Text & "Cliente >" & Text2.Text & vbCrLf
Text1.SelStart = Len(Text1.Text)
Text2.Text = ""
End If
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim Buffer As String 'variable para guardar los datos
'obtenemos los datos y los guardamos en una variable
Winsock1.GetData Buffer, vbString, 80
'apuntamos al final del contenido del TextBox e
'insertamos los nuevos datos obtenidos
Text1.SelStart = Len(Text1.Text) 'coloca el cursor al final del contenido
Text1.Text = Text1.Text & "Servidor >" & Buffer 'mostramos los datos
Text1.SelStart = Len(Text1.Text) 'coloca el cursor al final del contenido
End Sub
'ERRORES
Private Sub Winsock1_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)
'cerramos la conexion
Winsock1.Close
'mostramos informacion sobre el error
MsgBox "Error numero " & Number & ": " & Description, vbCritical
End Sub
Sangrientas Lunas!¡.