Receives data through the connection.


Data = SRP_TcpClient(Object, "SEND", BytesToRead, BytesActuallyRead)


The data read.


BytesToReadThe number of bytes to read.
BytesActuallyReadThe number of bytes actually read.


The RECEIVE service reads a string of data from the remote server. While the call is simple, using it correctly is not. You must always keep in mind that the data you send is treated as an array of bytes. Therefore, if the server on the other sends a 32-bit integer value, you must read four bytes (or chars) and convert it from a 32-bit integer into an OI number. What the server sends to you all depends on its TCP/IP protocol. You'll have to refer to the server's documentation for that information.

Note also that this method causes OI to wait for as long as possible for data to come in. If it takes an hour, OI will wait for an hour.

Pass the number of bytes you are expecting via the BytesToRead parameter, and pass an empty variable to the BytesActuallyRead parameter. BytesActuallyRead will be set to 0 or more bytes actually read. If it is 0, this means the connection to the server was lost.


// Connect to a local socket, receive 10 bytes, and then close 
TcpClientHandle = 0 
If SRP_TcpClient(TcpClientHandle, "CONNECT", "", "7777") then 
    // Receive the bytes
	BytesToRead = 10
	BytesActuallyRead = 0
    Data = SRP_TcpClient(TcpClientHandle, "RECEIVE", BytesToRead, BytesActuallyRead) 
    // Close 
    SRP_TcpClient(TcpClientHandle, "CLOSE") 
  • No labels