Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/05/2008, 14:43
magTpeak
 
Fecha de Ingreso: septiembre-2007
Mensajes: 189
Antigüedad: 16 años, 8 meses
Puntos: 1
Sonrisa Porque no me function este codigo?

Hola, tengo este codigo visual basic: ( que lo consegui de aqui: http://www.monografias.com/trabajos3...al-basic.shtml)
Código:
   
 
Private Sub Command2_Click()
    Winsock1.Close
    Winsock1.LocalPort = 9900
    Winsock1.Listen
    Text1.SelStart = Len(Text1.Text)
    Text1.Text = Text1.Text & "*** Servidor encendido." & vbCrLf
    Text1.SelStart = Len(Text1.Text)
End Sub

Private Sub Command3_Click()
    Winsock1.Close
    Text1.SelStart = Len(Text1.Text)
    Text1.Text = Text1.Text & "*** Servidor Cerrado." & vbCrLf
    Text1.SelStart = Len(Text1.Text)
End Sub

Private Sub Winsock1_Close()
    Text1.SelStart = Len(Text1.Text)
    Text1.Text = Text1.Text & "*** Client BYEBYE." & vbCrLf
    Text1.SelStart = Len(Text1.Text)
End Sub

Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
    
    'cerramos previamente el socket
    Winsock1.Close
    
    'aceptamos la conexion
    Winsock1.Accept requestID
    
    'desplegamos un mensaje en la ventana
    Text1.SelStart = Len(Text1.Text)
    Text1.Text = Text1.Text & "*** Cliente enter, welcome!" & vbCrLf
    Winsock1.SendData "Welcome" & vbCrLf
    Text1.SelStart = Len(Text1.Text)
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    Dim Buffer As String '
    
    Winsock1.GetData Buffer
If Buffer = "110" Then
Winsock1.SendData "Usuario:" & vbCrLf
End If

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)
    'cerramos la conexion
    Winsock1.Close
    
    'mostramos informacion sobre el error
    MsgBox "Error numero " & Number & ": " & Description, vbCritical
End Sub
El problema esta aqui:
Código:
If Buffer = "110" Then
Winsock1.SendData "Usuario:" & vbCrLf
End If
No se envia ningun dato al cliente
La variable buffer este definida, porque si pongo esto:
Código:
msgbox buffer, vbcritical
si que me pone el mensaje que envia el cliente
El problema pampoco este en
Código:
Winsock1.SendData "Usuario:" & vbCrLf
Porque si lo pongo por separado envia los datos al cliente perfectamente.
Entonces, cual es el problema?
Gracias y un saludo