Hello. I'm new here but I will try to do my best.
Currently, I am trying to do an Ethernet communication with an industrial equipment. That equipment works as a server through port 23 and send me (to my vb.net app) a command to start communication. After receiving that command, I have to send the character 'A' as an answer.
The problem: when I send the 'A', my VB.NET app send a Null after it. That happens when I send anything through the ethernet port. it Always sends a Null at the end of any data I send. I have tried sending the data as a string "A", converting it to a Byte array, and as a simple byte.
What can be happening? How can I avoid sending that Null? I will appreciate your help so much.
I'm working with VS2013 in VB.NET with .NET Framework 4.5.1. My OS is Windows 10
This is the code I'm working with...
This is the function I use to connect to the server.
wo methods I'm working with to send data.
And finally my implementation...
MyEthernet.send("A")
MyEthernet.send(Convert.ToByte(65))
In both cases My App sends a Null at the end of the data.
Currently, I am trying to do an Ethernet communication with an industrial equipment. That equipment works as a server through port 23 and send me (to my vb.net app) a command to start communication. After receiving that command, I have to send the character 'A' as an answer.
The problem: when I send the 'A', my VB.NET app send a Null after it. That happens when I send anything through the ethernet port. it Always sends a Null at the end of any data I send. I have tried sending the data as a string "A", converting it to a Byte array, and as a simple byte.
What can be happening? How can I avoid sending that Null? I will appreciate your help so much.
I'm working with VS2013 in VB.NET with .NET Framework 4.5.1. My OS is Windows 10
This is the code I'm working with...
Code:
Private WithEvents TCClient As TcpClient
Private TCPThread As Thread
Dim Stream As NetworkStream
Private ReadThread As Thread
Private _IPAddress As string = "10.0.8.234"
Private _intPort As Integer = 23
Code:
Private Overloads Function Connect() As Boolean
Try
TCClient = New TcpClient
If Not TCClient.Connected Then
TCClient.Connect(Me._IPAddress, Me._intPort)
If TCClient.Connected Then
TCClient.NoDelay = True
Stream = TCClient.GetStream()
TCPThread = New Thread(AddressOf ReadData)
TCPThread.Start()
Return True
End If
End If
Return True
Catch ex As Exception
TCClient.Close()
End Try
Return False
End Function
wo methods I'm working with to send data.
Code:
Public Overloads Function send(ByVal _byte As Byte) As Boolean
Try
If Not (Stream Is Nothing) Then
Stream.WriteByte(_byte)
End If
Return True
Catch ex As Exception
Return False
End Try
End Function
Code:
Public Overloads Function send(ByVal data As String) As Boolean
Try
Dim BufferDeEscritura() As Byte
BufferDeEscritura = Encoding.ASCII.GetBytes(data)
If Not (Stream Is Nothing) Then
Stream.Write(BufferDeEscritura, 0, BufferDeEscritura.Length)
End If
Return True
Catch ex As Exception
Return False
End Try
End Function
MyEthernet.send("A")
MyEthernet.send(Convert.ToByte(65))
In both cases My App sends a Null at the end of the data.