hola,
Estoy haciendo un programa cliente/servidor el cual utiliza winsock
es muy sencillo, se trata de un contador el cual cuando en el servidor se oprima un boton en el cliente el contador inicie, he tomado como idea que cuando se oprima el boton el dato que se envie sea una variable llamada buffer de tipo string la cual diga "tiempo" o algo parecidoy en el cliente la muestre en un textbox pero cuando le digo que si buffer = "tiempo" no hace nada coloco mi codigo para que me entiendan
CODIGO:
***Cliente
Private Sub Command1_Click()
Dim DatosaEnviar As String
DatosaEnviar = Text2.Text
Winsock1.SendData DatosaEnviar
Text1.Text = DatosaEnviar
Text2.Text = ""
End Sub
Private Sub Command2_Click()
Winsock1.RemoteHost = Text3.Text
Winsock1.RemotePort = Text4.Text
Winsock1.Close
Winsock1.Connect
End Sub
Private Sub Command3_Click()
Winsock1.Close
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer2.Enabled = False
End Sub
Private Sub Text1_Change()
Select Case Text1.Text
Case "Tiempo":
Timer1.Enabled = True
Timer2.Enabled = True
Case "Parar":
Timer1.Enabled = False
Label1.Caption = "00"
Label2.Caption = "00"
Label3.Caption = "00"
Timer2.Enabled = False
Label6.Caption = "0"
End Select
End Sub
Private Sub Winsock1_Close()
Winsock1.Close
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim Buffer As String
Winsock1.GetData Buffer
Text1.Text = ""
Text1.Text = Buffer
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
End Sub
Private Sub Timer1_Timer()
Label6.Caption = "0"
Label3.Caption = Val(Label3.Caption) + 1
If Val(Label3.Caption) < 10 Then
Label3.Caption = "0" & Label3.Caption
End If
If Val(Label3.Caption) > 59 Then
Label3.Caption = "00"
Label7.Caption = Val(Label7.Caption) + 1
If Val(Label7.Caption) < 10 Then
Label7.Caption = "0" & Label7.Caption
End If
If Val(Label7.Caption) > 59 Then
Label7.Caption = "00"
Label8.Caption = Val(Label8.Caption) + 1
If Val(Label1.Caption) < 10 Then
Label1.Caption = "0" & Label1.Caption
End If
End If
End If
End Sub
Private Sub Timer2_Timer()
Label6.Caption = Val(Label6.Caption) + 1
End Sub
***Servidor
Private Sub Command1_Click()
Winsock1.SendData Text2.Text
Text1.SelStart = Len(Text1.Text)
Text1.Text = Text2.Text
Text1.SelStart = Len(Text1.Text)
Text2.Text = ""
End Sub
Private Sub Command2_Click()
Winsock1.Close
Winsock1.LocalPort = Text3.Text
Winsock1.Listen
End Sub
Private Sub Command3_Click()
Winsock1.Close
End Sub
Private Sub Winsock1_Close()
Winsock1.Close
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
Winsock1.Close
Winsock1.Accept requestID
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim Buffer As String
Winsock1.GetData Buffer
Text1.Text = Buffer
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
End Sub
Nota: Ya he probado el timer solo y funciona, ya probe solo enviarme a modo de chata y funciona, no se que pasa que no reconoce la palabra para iniciar el cronometro.
por favor diganme donde esta el erro, quiero agregar que la es una monoconexion (Un solo Cliente - Un solo Servidor)
Gracias de Antemano
Juan Manuel Lombana