elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Estamos en la red social de Mastodon


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  VB 6.0 [Error 40020]
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: VB 6.0 [Error 40020]  (Leído 1,772 veces)
GranDestello

Desconectado Desconectado

Mensajes: 16



Ver Perfil
VB 6.0 [Error 40020]
« en: 3 Julio 2014, 03:03 am »

Buenas gente del foro :D , esta vez vengo con una pregunta nuevamente :S tengo problemas con el control Winsock e.e! no se porque nunca logro conectarme de manera efectiva con otra pc :S hasta donde veo siempre hago todo bn.

Hoy probando con un amigo nos salto el error 40020 :S no se xq, cuando pruebo el programa con mi mismo Host todo anda bien, pero al probarlo con otros siempre me da error, agradezco su ayuda de ANTEMANO :D.

CODIGO SERVIDOR:

Citar
Option Explicit

Private Sub Winsock1_Close()
Winsock1.Close
TxtPanel.SelStart = Len(TxtPanel.Text)
TxtPanel.Text = TxtPanel.Text & "*** Conexion cerrada por el cliente." & vbCrLf
TxtPanel.SelStart = Len(TxtPanel.Text)
End Sub


Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
'Decirnos que alguien se esta conectando
TxtPanel.SelStart = Len(TxtPanel.Text)
TxtPanel.Text = TxtPanel.Text & "*** Peticion numero " & requestID & vbCrLf
TxtPanel.SelStart = Len(TxtPanel.Text)
'Cerramos
Winsock1.Close
'Aceptamos la conexion
Winsock1.Accept requestID
Text1.Text = Winsock1.RemoteHostIP
'Desplazamos un mensaje en la ventana
TxtPanel.SelStart = Len(TxtPanel.Text)
TxtPanel.Text = TxtPanel.Text & "*** Conexion aceptada, listo para interactuar." & vbCrLf
TxtPanel.SelStart = Len(TxtPanel.Text)
End Sub


Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
'Controla los datos que son recibidos
'Declaramos donde se guardaran los datos que envie el cliente el cual se llamara "Buffer"

Dim Buffer As String 'variable para guardar los datos
'Recibe los datos guardados en la variable "Buffer"
Winsock1.GetData Buffer
TxtPanel.SelStart = Len(TxtPanel.Text)
TxtPanel.Text = TxtPanel.Text & "Cliente >" & Buffer 'Mostramos los datos de texto =O!
TxtPanel.SelStart = Len(TxtPanel.Text)
End Sub


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)
Winsock1.Close
MsgBox "Error numero " & Number & "| " & Description, vbCritical
End Sub

'---------------CONTROLES

Private Sub CmdDesconectar_Click()
Winsock1.Close
End Sub

Private Sub CmdEnviar_Click()
Winsock1.SendData TxtMensaje.Text & vbCrLf
TxtPanel.SelStart = Len(TxtPanel.Text)
TxtPanel.Text = TxtPanel.Text & "Servidor >> " & TxtMensaje.Text & vbCrLf 'Mostramos los datos
TxtPanel.SelStart = Len(TxtPanel.Text)
TxtMensaje.Text = ""
End Sub

Private Sub CmdEscuchar_Click()
Winsock1.Close 'Cerrar conexiones anteriores
Winsock1.LocalPort = TxtPuerto.Text
Winsock1.Listen
TxtPanel.SelStart = Len(TxtPanel.Text)
TxtPanel.Text = TxtPanel.Text & "*** Escuchando conexiones, (Puerto " & TxtPuerto.Text & ")" & vbCrLf
TxtPanel.SelStart = Len(TxtPanel.Text)
End Sub

CODIGO CLIENTE:

Citar
Private Sub CmdConectar_Click()
Winsock1.RemoteHost = TxtServidor.Text
If TxtServidor.Text = "" Then MsgBox "introduzca un servidor en el campo"
If TxtPuerto.Text = "" Then MsgBox "introduzca un puerto en el campo"
Winsock1.RemotePort = TxtPuerto.Text
Winsock1.Close
Winsock1.Connect
End Sub

Private Sub CmdDesconectar_Click()
Winsock1.Close
TxtPanel.Text = TxtPanel.Text & "*** Conexion cerrada por el usuario." & vbCrLf
TxtPanel.SelStart = Len(TxtPanel.Text)
End Sub

Private Sub CmdEnviar_Click()
Winsock1.SendData TxtMensaje.Text & vbCrLf
TxtPanel.SelStart = Len(TxtPanel.Text)
TxtPanel.Text = TxtPanel.Text & "Cliente >" & TxtMensaje.Text & vbCrLf 'Mostramos los datos
TxtPanel.SelStart = Len(TxtPanel.Text)
TxtMensaje.Text = ""
End Sub

Private Sub Form_Load()
TxtPanel.Text = TxtPanel.Text & "*** Aun no introduce los valores para conectarse a algun servidor" & vbCrLf
End Sub

Private Sub Winsock1_Close()
Winsock1.Close
TxtPanel.SelStart = Len(TxtPanel.Text)
TxtPanel.Text = TxtPanel.Text & "*** Conexion Cerrada Por El Servidor" & vbCrLf
TxtPanel.SelStart = Len(TxtPanel.Text)
End Sub

Private Sub Winsock1_connect()
TxtPanel.Text = TxtPanel.Text & "*** Conexion Establecida." & vbCrLf
TxtPanel.SelStart = Len(TxtPanel.Text)
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim Buffer As String
Winsock1.GetData Buffer
TxtPanel.SelStart = Len(TxtPanel.Text)
TxtPanel.Text = TxtPanel.Text & "Servidor >" & Buffer
TxtPanel.SelStart = Len(TxtPanel.Text)
End Sub

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)
Winsock1.Close
MsgBox "Error numero " & Number & "| " & Description, cbCritical
End Sub

Saludos a todos agradezco su ayuda  :laugh: ;-)


En línea

No dejes que los errores de tu pasado afecten tu futuro
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines