- Posts: 5
- Joined: Mon Nov 01, 2021 6:11 am
- Real Name: Sergey Rodionov
There is code, that sending "record" command to Hyperdeck, but it doesn't work
If I change IP or PORT it returns exception, from which I conclude that the request is being sent, but not executed. where could the error be?
If I change IP or PORT it returns exception, from which I conclude that the request is being sent, but not executed. where could the error be?
- Code: Select all
Dim clientIP as String = "192.168.11.233"
Dim clientPort as String = "9993"
Dim message as String = "record"
Dim client As New System.Net.Sockets.TcpClient(clientIP, clientPort)
client.SendTimeout = 1000
client.ReceiveTimeout = 1000
' Translate the passed message into ASCII and store it as a Byte array.
Dim data As [Byte]() = System.Text.Encoding.ASCII.GetBytes(message)
' Get a client stream for reading and writing.
Dim stream As System.Net.Sockets.NetworkStream = client.GetStream()
' Send the message to the connected TcpServer.
stream.Write(data, 0, data.Length)
' Receive the TcpServer.response.
' Buffer to store the response bytes.
data = New [Byte](256) {}
If stream.CanRead Then
Dim myReadBuffer(1024) As Byte
Dim myCompleteMessage As System.Text.StringBuilder = New System.Text.StringBuilder
Dim numberOfBytesRead As Integer = 0
' Incoming message may be larger than the buffer size.
Do
Try
Threading.Thread.Sleep(100)
numberOfBytesRead = stream.Read(myReadBuffer, 0, myReadBuffer.Length)
myCompleteMessage.AppendFormat("{0}", System.Text.Encoding.ASCII.GetString(myReadBuffer, 0, numberOfBytesRead))
Catch ex As Exception
stream.Close()
client.Close()
Exit Sub
End Try
Loop While stream.DataAvailable
' Close everything.
stream.Close()
client.Close()
Exit Sub
Else
Exit Sub
End If