Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: GranDestello en 14 Enero 2014, 02:41 am



Título: Problemas con chat en Visual Basic 6.0
Publicado por: GranDestello en 14 Enero 2014, 02:41 am
Buenas gente, escribo en esta gran web para ver si me pueden brindar ayuda con unos problemas que tengo con un chat :S, veran cuando lo uso en mi misma pc me anda perfecto, pero al momento de probarlo con amigos me suelta varios errores como lo son:

Error 10060: Se ha sobrepasado el tiempo de conexion
Error 4006: Protocolo o estado de conexion erroneo para la transaccion o peticion solicitada.

CODIGOS DEL PROYECTO:

---SERVIDOR:

Private Sub command1_Click()
Winsock1.Close
Winsock1.LocalPort = 23
Winsock1.Listen
command2.Enabled = True
Text1 = Textt & "[Servidor] -Servidor de Chat Iniciando en Puerto: " & Winsock1.LocalPort & vbCrLf

End Sub

Private Sub command2_Click()
If Text2.Text = "" Then
Else
Winsock1.SendData Text2
Text1 = Text1 & "[Servidor] - " & Text2 & vbCrLf
Text2 = ""
End If
End Sub

Private Sub Form_Load()
command2.Enabled = False
End Sub

Private Sub winsock1_ConnectionRequest(ByVal requestID As Long)
If Winsock1.State <> sckClosed Then
Winsock1.Close
Else
End If
Winsock1.Accept requestID
Text1 = Text1 & "(Servidor) - Cliente conectado desde la ip: " & Winsock1.RemoteHostIP & vbCrLf

End Sub

Private Sub winsock1_DataArrival(ByVal bytesTotal As Long)
Dim datos As String
Winsock1.GetData datos
Text1 = Textt1 & "(Cliente) - " & datos & vbCrLf


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)
    MsgBox Number & ": " & Description
End Sub



---CLIENTE

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

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

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

Private Sub Command1_Click()
Winsock1.SendData Text2.Text & vbCrLf
Text1.SelStart = Len(Text1.Text) 'coloca el cursor al final del contenido
Text1.Text = Text1.Text & "Cliente >" & Text2.Text & vbCrLf 'mostramos los datos
Text1.SelStart = Len(Text1.Text)
Text2.Text = ""
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim Buffer As String
Winsock1.GetData Buffer
Text1.SelStart = Len(Text1.Text)
Text1.Text = Text1.Text & "Servidor >" & Buffer
text1.SelStart = Len(Text1.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

----------------------------------------------[/left]

muchas gracias de antemano, y mil disculpas si me equivoque en alguna cosa que publique en este tema, :)