Lo que estoy haciendo es una aplicacion cliente servidor. Yo tengo un microcontrolador que sensa datos, los manda a la pc por puerto serie y despues los manda a un servidor.
Cuando pruebo ambos (cliente y servidor) en mi maquina, anda bien, pero cuando pruebo el servidor en otra maquina, no recibe los datos que envia el cliente.
Te adjunto los dos codigos:
Cliente:
Option Explicit
Dim Cadena As String
Dim t As Double
Public contador As Integer, variable As Boolean, Fecha As String, Hora As String, puertos As String
Public Temperatura As Double, Presion As Double, Humedad As Double
Public Ti As Integer, Pi As Integer, Hi As Integer
Const MAX = 15
Private Sub cargar_Click()
ete:
        dialogo.Filter = "txt|*.txt"
        dialogo.DialogTitle = "Cargar un archivo"
        dialogo.ShowOpen
        If dialogo.FileName = "" Then Exit Sub
        Cadena = dialogo.FileName
        Open Cadena For Output As #1
        On Error GoTo ete
        cargar.Enabled = False
        'Abre el puerto seleccionado
         MSComm1.PortOpen = True
End Sub
Private Sub cliente_Close()
Label1.Caption = "Sin conexión"
End Sub
Private Sub cliente_Connect()
Label1.Caption = "Conectado"
End Sub
Private Sub cliente_ConnectionRequest(ByVal requestID As Long)
cliente.Close
cliente.Accept requestID
End Sub
Private Sub Command1_Click()
If Combo1.Text <> "" And (Asc(Combo1.Text) > 47 And Asc(Combo1.Text) < 58) Then
MSComm1.CommPort = Int(Combo1.Text)
Combo1.Enabled = False
Command1.Enabled = False
cargar.Enabled = True
End If
End Sub
Private Sub Command2_Click()
cliente.Protocol = sckTCPProtocol
cliente.RemoteHost = Text1.Text
cliente.LocalPort = 0
cliente.RemotePort = 7381
cliente.Connect
Text1.Enabled = False
Command2.Enabled = False
End Sub
Private Sub Form_Load()
        
        cargar.Enabled = False
        'Determina: 9600-Velocidad en Baudios, N-No utiliza ninguna paridad,
        '8-Cantidad de bits de envio y recepcion por paquete,
        '1-Determina los bits de parada
        MSComm1.Settings = "9600,N,8,1"
        'No existe control de flujo
        MSComm1.Handshaking = comNone
        'Lee todo el buffer de entrada para que quede vacio
        MSComm1.InputLen = 0
        'Cada vez que se recibe un caracter se producira el evento onComm
        MSComm1.RThreshold = 1
        t = 0
        contador = 10
        variable = False
        Temperatura = 0
        Presion = 0
        Humedad = 0
        Ti = 0
        Pi = 0
        Hi = 0
        'Nombre de los ejej X e Y
        GR.Axes(1).Caption = " Tiempo[seg]"
        GR2.Axes(1).Caption = " Tiempo[seg]"
        GR3.Axes(1).Caption = " Tiempo[seg]"
        GR.Axes(2).Caption = " Temperatura[ºC]"
        GR2.Axes(2).Caption = " Presión[Hp]"
        GR3.Axes(2).Caption = " Humedad[%]"
        'Color de las graficas. Por defecto GR2 es verde
        GR.Plots(1).LineColor = vbRed
        GR3.Plots(1).LineColor = vbBlue
        'Escala del eje Y
        GR.Axes(2).AutoScale = False
        GR.Axes(2).Minimum = 0
        GR.Axes(2).Maximum = 255
        GR2.Axes(2).AutoScale = False
        GR2.Axes(2).Minimum = 0
        GR2.Axes(2).Maximum = 255
        GR3.Axes(2).AutoScale = False
        GR3.Axes(2).Minimum = 0
        GR3.Axes(2).Maximum = 2.55
        With Combo1
        .AddItem 1
        .AddItem 2
        .AddItem 3
        .AddItem 4
        .AddItem 5
        .AddItem 6
        .AddItem 7
        .AddItem 8
        .AddItem 9
        .AddItem 10
        End With
                
End Sub
Private Sub Form_Unload(Cancel As Integer)
If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False
End If
Close #1
cliente.Close
End Sub
Private Sub MSComm1_OnComm()
    Dim valor As String, YE As Integer
    If MSComm1.CommEvent = comEvReceive Then
    valor = MSComm1.Input
    Select Case Left(valor, 1)
    Case "T"
    contador = 0
    If cliente.State = 7 Then
    cliente.SendData Left(valor, 1)
    Else: Label1.Caption = "Sin conexión"
    End If
    Case "P"
    contador = 1
    If cliente.State = 7 Then
    cliente.SendData Left(valor, 1)
    Else: Label1.Caption = "Sin conexión"
    End If
    Case "H"
    contador = 2
    If cliente.State = 7 Then
    cliente.SendData Left(valor, 1)
    Else: Label1.Caption = "Sin conexión"
    End If
    End Select
    If contador = 0 And Left(valor, 1) <> "T" And Left(valor, 1) <> "P" And Left(valor, 1) <> "H" Then
    YE = Asc(Right(valor, 1))
    Temperatura = Temperatura + YE
    Ti = Ti + 1
    If Ti = MAX Then
    Temperatura = Temperatura / Ti
    'Trunco a dos decimales
    Temperatura = FormatNumber(Temperatura, 2)
    GR.ChartXvsY t, Temperatura
    Ti = 0
    Label2.Caption = Temperatura & " Grados Celsius"
    t = t + 1
    Print #1, Temperatura & " grados Celsius"
    If cliente.State = 7 Then
    cliente.SendData Str(Temperatura)
    Else: Label1.Caption = "Sin conexión"
    End If
    Temperatura = 0
    End If
    End If
    If contador = 1 And Left(valor, 1) <> "T" And Left(valor, 1) <> "P" And Left(valor, 1) <> "H" Then
    YE = Asc(Right(valor, 1))
    Presion = Presion + YE
    Pi = Pi + 1
    If Pi = MAX Then
    Presion = Presion / Pi
    'Trunco a dos decimales
    Presion = FormatNumber(Presion, 2)
    GR2.ChartXvsY t, Presion
    Pi = 0
    Label6.Caption = Presion & " Hecto pascales"
    t = t + 1
    Print #1, Presion & " hecto pascales"
    If cliente.State = 7 Then
    cliente.SendData Str(Presion)
    Else: Label1.Caption = "Sin conexión"
    End If
    Presion = 0
    End If
    End If
    If contador = 2 And Left(valor, 1) <> "T" And Left(valor, 1) <> "P" And Left(valor, 1) <> "H" Then
    YE = Asc(Right(valor, 1))
    Humedad = Humedad + YE
    Hi = Hi + 1
    If Hi = MAX Then
    Humedad = Humedad / Hi
    Humedad = Humedad / 100
    'Trunco a dos decimales
    Humedad = FormatNumber(Humedad, 2)
    GR3.ChartXvsY t, Humedad
    Hi = 0
    Label8.Caption = Humedad & " %"
    t = t + 1
    variable = True
    Print #1, Humedad / 100 & " %"
    If cliente.State = 7 Then
    cliente.SendData Str(Humedad)
    Else: Label1.Caption = "Sin conexión"
    End If
    Humedad = 0
    End If
    End If
    If variable = True Then
    Fecha = Date$
    Hora = Time$
    Print #1, Fecha
    Print #1, Hora
    variable = False
    End If
    End If
End Sub
Private Sub acercade_Click()
AD.Show vbModal
End Sub
Programa Servidor:
Public Variable As String, tiempo As Integer, contador As Integer
Public Temperatura As String, Presion As String, Humedad As String
Public llave As Boolean
Const Lim = 75
Private Sub acercade_Click()
AD.Show vbModal
End Sub
Private Sub Form_Load()
        GR.Axes(1).Caption = " Tiempo[seg]"
        GR2.Axes(1).Caption = " Tiempo[seg]"
        GR3.Axes(1).Caption = " Tiempo[seg]"
        GR.Axes(2).Caption = " Temperatura[ºC]"
        GR2.Axes(2).Caption = " Presión[Hp]"
        GR3.Axes(2).Caption = " Humedad[%]"
        GR.Plots(1).LineColor = vbRed
        GR3.Plots(1).LineColor = vbBlue
        GR.Axes(2).AutoScale = False
        GR.Axes(2).Minimum = 0
        GR.Axes(2).Maximum = 255
        GR2.Axes(2).AutoScale = False
        GR2.Axes(2).Minimum = 0
        GR2.Axes(2).Maximum = 255
        GR3.Axes(2).AutoScale = False
        GR3.Axes(2).Minimum = 0
        GR3.Axes(2).Maximum = 2.55
        
        Temperatura = 0
        tiempo = 0
        contador = 0
        llave = True
                        
        servidor.Protocol = sckTCPProtocol
        servidor.LocalPort = 7381
        servidor.RemotePort = 0
        servidor.Listen
                
End Sub
Private Sub Form_Unload(Cancel As Integer)
        servidor.Close
End Sub
Private Sub servidor_ConnectionRequest(ByVal requestID As Long)
        
        servidor.Close
        servidor.Accept requestID
        
End Sub
Private Sub servidor_DataArrival(ByVal bytesTotal As Long)
        servidor.GetData Variable
        Select Case Variable
        Case "T"
        contador = 1
        Case "P"
        contador = 2
        Case "H"
        contador = 3
        End Select
        If contador = 1 And Variable <> "T" And Variable <> "P" And Variable <> "H" Then
        GR.ChartXvsY tiempo, Val(Variable)
        Label2.Caption = Val(Variable) & " Grados Celsius"
        contador = 0
        List1.AddItem (Variable & " Grados Celsius")
        End If
        If contador = 2 And Variable <> "T" And Variable <> "P" And Variable <> "H" Then
        GR2.ChartXvsY tiempo, Val(Variable)
        Label3.Caption = Val(Variable) & " Hecto pascales"
        contador = 0
        List1.AddItem (Variable & " Hecto pascales")
        End If
        If contador = 3 And Variable <> "T" And Variable <> "P" And Variable <> "H" Then
        GR3.ChartXvsY tiempo, Val(Variable)
        tiempo = tiempo + 1
        Label5.Caption = Val(Variable) & " %"
        contador = 0
        List1.AddItem (Variable & " %")
        End If
        
End Sub
Private Sub servidor_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)
        
        servidor.Close
        
End Sub