I am trying a new approach to my data capture/monitor project. I have read up on a lot of vb.net UDP actions and methods and I have had some success. However, I am now at a loss. I have a server that listens on a thread for data that arrives and shows the sender ip:port and the text received. This is derived from the code on this technotif page:
With their example and a bit of tweaking as it was written before VS2017, I got both sender and receiver to work. My next step was to break out of seeing both IP and text received in one box because I want to display them separately and use a traffic light if data is lost as the datastream will be 24H7. The ultimate app goal is to handle what could be multiple UDP datagrams (up to 12 from outside my local network), all sources identified in a list box, capture the dat in hex and write to a file for 1 hour and then recapture and of course in parallel will be a window showing that all identified sources are still being received so if one is lost a label will turn from green to red.
The latest hurdle I can't seem to get over is that any of the lines after Line 18 line throws an invalidoperationexception and I can't figure out why. All I have done is split the original concatenated text into two boxes and added a color change to the text box, which was working fine.
I have added snips of the exception and the thread menu item.
Appreciate any thoughts.
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim ThdUDPServer = New Thread(New ThreadStart(AddressOf ServerThread))
Public Sub ServerThread()
Dim UdpClient As New UdpClient(8080)
Dim RemoteIpEndPoint As New IPEndPoint(IPAddress.Any, 0)
Dim ReceiveBytes As Byte()
ReceiveBytes = UdpClient.Receive(RemoteIp
Dim ReturnData As String = Encoding.ASCII.GetString(R
TxtDataRx.BackColor = Color.Green
TxtDataRx.Text = TxtDataRx.Text & vbCrLf & returnData.ToString()