Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.
SRP_TcpClient "SEND"
When I attempt to send data to a server using the utility SRP_TcpClient, the function breaks with the runtime error in the OI Debugger:
"ENG0016: SRP_TCPCLIENT, line 75. Non-numeric data when numeric required. Zero used."
I went back to test it with the example code on the website using the debugger to see what is happening on each line of code:
// Connect to a local socket, send data, and then close
TcpClientHandle = 0
If SRP_TcpClient(TcpClientHandle, "CONNECT", "127.0.0.1", "7777") then
// Send the string length in binary
SRP_TcpClient(TcpClientHandle, "SEND", \0000000D\)
// Send the string
SRP_TcpClient(TcpClientHandle, "SEND", "Hello, World!")
// Close
SRP_TcpClient(TcpClientHandle, "CLOSE")
end
I found that when it tries to send the \0000000D\, it gives the same runtime error. I have tried the following commands with the following results in a socket test software as the listening server:
SRP_TcpClient(TcpClientHandle, "SEND_SES", "Hello, World!")
Result: the data transmits with Hex 04 00 00 00 0D before the "Hello, World!" chars
SRP_TcpClient(TcpClientHandle, "SEND", 13)
SRP_TcpClient(TcpClientHandle, "SEND", "Hello, World!")
Result: The first line will not trigger a runtime error, but no data is passed to the server. The second line results in the runtime error.
What am I missing?
"ENG0016: SRP_TCPCLIENT, line 75. Non-numeric data when numeric required. Zero used."
I went back to test it with the example code on the website using the debugger to see what is happening on each line of code:
// Connect to a local socket, send data, and then close
TcpClientHandle = 0
If SRP_TcpClient(TcpClientHandle, "CONNECT", "127.0.0.1", "7777") then
// Send the string length in binary
SRP_TcpClient(TcpClientHandle, "SEND", \0000000D\)
// Send the string
SRP_TcpClient(TcpClientHandle, "SEND", "Hello, World!")
// Close
SRP_TcpClient(TcpClientHandle, "CLOSE")
end
I found that when it tries to send the \0000000D\, it gives the same runtime error. I have tried the following commands with the following results in a socket test software as the listening server:
SRP_TcpClient(TcpClientHandle, "SEND_SES", "Hello, World!")
Result: the data transmits with Hex 04 00 00 00 0D before the "Hello, World!" chars
SRP_TcpClient(TcpClientHandle, "SEND", 13)
SRP_TcpClient(TcpClientHandle, "SEND", "Hello, World!")
Result: The first line will not trigger a runtime error, but no data is passed to the server. The second line results in the runtime error.
What am I missing?
Comments
BytesToRead = 10 Data = SRP_TcpClient(Handle, "RECEIVE", BytesToRead, BytesActuallyRead)
You pass in the number of bytes you want to read, the BytesActuallyRead variable tells you how much was actually read. NOTE: This method will wait for data. So, if there is no data available, it will sit there waiting for it. If it returns 0 bytes read, then the connection to the server ended.
Truth be told, I'm actually on site at a client's, so I couldn't really test it. Glad it worked.