Hello, I need to get data from a matrix code reader connected to a PC through the ethernet port and a TCP IP address.
I set everything up and tried to see if the device works with the Hercules program, and in fact I see the data read,
But I should build an application in vb.net that uses this data, so when a code passes under the laser I should intercept it in my application.
I tried with various sockets but I can't, as long as it is chat it works but capturing the data from the device nothing.
Below is the code of the client which, however, sends what is in the textbox. Instead I would like it to send what I read from the 2D code reader which is always active.
What I have tried:
Imports System.Net, System.Net.Sockets
Public Class frm_Client
Dim client As Socket
Dim host As String = "127.0.0.1" '"192.168.3.100"
'Dim port As Integer = "6969" '"51236"
Dim port As Integer = "51236"
Private Sub frm_Client_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Private Sub btnConnect_Click(sender As Object, e As EventArgs) Handles btnConnect.Click
client = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
Dim IP As IPAddress = IPAddress.Parse(host)
Dim xIpEndPoint As IPEndPoint = New IPEndPoint(IP, port)
client.BeginConnect(xIpEndPoint, New AsyncCallback(AddressOf OnConnect), Nothing)
btnConnect.Enabled = False
Private Sub btnSend_Click(sender As Object, e As EventArgs) Handles btnSend.Click
Dim bytes As Byte() = ASCII.GetBytes(txtMessage.Text)
client.BeginSend(bytes, 0, bytes.Length, SocketFlags.None, New AsyncCallback(AddressOf OnSend), client)
Private Sub OnConnect(ByVal ar As IAsyncResult)
Private Sub OnSend(ByVal ar As IAsyncResult)