NetworkStream .Write Only sends data to client once then nothing happens?

Ian W

Active member
Joined
Feb 11, 2010
Messages
31
Programming Experience
1-3
Hi,

I'm looking at trying to re-write a vba app in .net. I'm new to .net and i'm stuck on a strange issue.

I have a remote device that is connected via the LAN, I can connect to it and send it a stream of text to display on the screen. However once its sent the first stream I try and send something else and nothing happens? If I step through the code it works just as you would expect but when run with no breaks nothing happens.

Its just a basic form with a text box and a button to send the contents of the text box to the device.

Here is my code

VB.NET:
        Dim clientSocket As New System.Net.Sockets.TcpClient()
        Dim netStream As System.Net.Sockets.NetworkStream
        Dim PoE_IP As String = "192.168.33.85"
        Dim PoE_Port As Integer = 10003
        Dim Output As String

        If My.Computer.Network.Ping(PoE_IP) Then
            Console.WriteLine("PoE unit pinged successfully.")
            clientSocket.Connect(PoE_IP, PoE_Port)
            If clientSocket.Connected Then
                Console.WriteLine("Connected to 192.168.33.85")
                netStream = clientSocket.GetStream()
                Output = "Display(0,0," & Len(Me.ToSend.Text) & ")" & Me.ToSend.Text
                netStream.Write(System.Text.Encoding.ASCII.GetBytes(Output), 0, Len(Output))
                netStream.Close()
                clientSocket.Close()
            End If
        Else
            MsgBox("Ping request timed out, unit plugged in?")
        End If

I did read somewhere that there is a bug in the .net stuff that can cause this ? Not sure if this is true though as I can't find anything else about it.
 
Back
Top