Sending Texture from Unity3d to openFrameworks -- noise

I am trying to send a texture (small 32x32 RGB24) from Unity3d to openFrameworks via Tcp. I am trying to recive the texture using bit modified ClientServer example I attached image so you can see how it looks like. Any toughts?

Here’s unity source code

using UnityEngine;  
using System;  
using System.Collections;  
using System.Net;  
using System.Net.Sockets;  
using System.IO;  
using System.Threading;  
public class rtTOtcp : MonoBehaviour  
	public RenderTexture rTexture;  
	public Texture2D sTexture;  
	public Texture2D retTexture;  
	//IPEndPoint ipEnd =   
	TcpListener listener = new TcpListener(new IPEndPoint (IPAddress.Parse (""), 9050));  
	TcpClient client;  
	public bool isConnected=false;  
	//sendImage2DMain = new Texture2D(sendRenderTextureMain.width, sendRenderTextureMain.height, TextureFormat.RGB24, false);  
	int dataSent = 0;  
	void Start ()  
		sTexture = new Texture2D (rTexture.width, rTexture.height, TextureFormat.RGB24,false);  
		retTexture = new Texture2D(rTexture.width,rTexture.height, TextureFormat.RGB24,false);  
		try {  
		} catch (SocketException ex) {  
			Debug.Log (ex.Message);	  
	void Update()  
			client = listener.AcceptTcpClient();  
	// Update is called once per frame  
	void OnPostRender ()  
	{ = rTexture;  
		sTexture.ReadPixels(new Rect (0, 0, rTexture.width, rTexture.height), 0, 0);  
		sTexture.Apply ();  
		dataSent = SendVarData (client, sTexture.EncodeToPNG());	  
	private static int SendVarData (TcpClient c, byte[] data)  
		int total = 0;  
		int size = data.Length;  
		int dataleft = size;  
		int sent;  
		byte[] datasize = new byte[0];  
		datasize = BitConverter.GetBytes (size);  
		//sent = c.Client.Send (datasize);  
		try {  
			while (total < size) {  
				sent = c.Client.Send (data, total, dataleft, SocketFlags.None);  
				total += sent;  
				dataleft -= sent;  
		} catch (Exception ex) {  
			Debug.Log (ex.Message);	  
		return total;  

And where oF magic happens

void testApp::setup(){  
	tex.allocate(32, 32,GL_RGB);  
	pixelsLoaded = false;  
void testApp::update(){  
	if( client.getState() == COMPLETE ){  
		tex.loadData(client.pixels, 32, 32, GL_RGB);  
		pixelsLoaded = true;  


i don’t know unity enough to answer your question, but have you considered syphon or the older UDP tile streamer

syphon worked fine for me the other way around, I wouldn’t imagine there would be any problems using it from Unity to oF.

I’m on windows. The texture isn’t that big it is 32x32 rgb24, so sending it via tcp should’t be a problem. I tried usig rgba32 format but also with no success