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 .
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
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
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