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

 

 


Tema destacado: Recuerda que debes registrarte en el foro para poder participar (preguntar y responder)


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


Desconectado Desconectado

Mensajes: 559


Erepublik.com


Ver Perfil
Error Winsok Cliente/Servidor
« en: 29 Agosto 2006, 17:39 pm »

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
Código:
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

Código:

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


En línea


Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
API Winsok 32
Programación Visual Basic
rembolso 1 1,849 Último mensaje 29 Abril 2012, 13:38 pm
por BlackZeroX
Ayuda por un error en una parte de código en un Cliente - Servidor
Programación Visual Basic
luis carlos0510 0 1,878 Último mensaje 30 Octubre 2013, 04:48 am
por luis carlos0510
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines