I need to send big fixed sized buffers from python to c/c++ code side. From python side I have buffers in form of:
array = np.zeros([1000], dtype=np.uint8)
array = fill(array)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('localhost', 1010))
Code below is used to recv data from connected socket from C/C++ side.From the c/c++ side I need to have this buffer as raw 1000 byte array, I don't need any headers, I need just data. Unfortunately I haven't found howto do it. In general np.tofile()
- makes things I need but in file.
int recvBuffer(uint8_t *p_buff, uint32_t size, int socket)
{
uint32_t recived = 0;
uint8_t *p_curr = p_buff;
while (recived < size)
{
int ret = recv(tcp_sock, p_curr, size - recived, 0);
if (ret != -1)
{
p_curr += ret;
recived += ret;
}
else
{
return false;
}
}
return true;
}