title: Sending data from Unity to Raspberry
body: <p>I'm trying to send data from Unity to Raspberry Pi. I have succesfully connected them but I can't pass any data please help.</p>
  
  <p>This is code that I use on the Raspberry side</p>
  
  <pre><code>import socket
  
  
  
  backlog=1
  size = 1024
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  s.bind(("169.254.242.100",50001))
  s.listen(backlog)
  try:
      print ( "is waiting")
      client, address = s.accept()
  
      while 1:
          data = client.recv(size)
          if data:
              tabela = data
              print ( "sends data")
              print (tabela[0])
  
              client.send(data)
  except:
      print("closing socket")
      client.close()
      s.close()
  </code></pre>
  
  <p>and this is the one I use in Unity</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  using System.Net.Sockets;
  
  public class UnityToRaspberry : MonoBehaviour {
  
  public string IP = "169.254.242.100"; //
  public int Port = 50001;
  
  public byte[] dane = System.Text.Encoding.ASCII.GetBytes("Hello");
  public Socket client;
  
  void Start(){
      //dane [0] = 1;
  
      client = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
      client.Connect (IP, Port);
      if (client.Connected) {
          Debug.Log ("Connected");
      }
      client.Send (dane);
  }
  
  void OnApplicationQuit(){
      client.Close();
  }
  
  
  
  }
  </code></pre>
  
  <p>Thank You!</p>