I started working on unity3d. I just want to send / receive data between Unity3D and Raspberry Pi. For this, I used socket programming. But when I try to connect my raspberry Pi, Unity sends me the error message "Failed to connect because a valid cross-domain policy was not found." Why cross-domain policy is needed. I just want to send or receive data between my computer and raspberries. Can I turn off cross-domain policy request or how to solve this problem.
public static void StartClient() {
byte[] bytes = new byte[1024];
int remotePort = xxxx;
try {
IPHostEntry ipHostInfo = Dns.GetHostEntry("xxx.xxx.xxx.xxx");
IPAddress ipAddress = ipHostInfo.AddressList[0];
IPEndPoint remoteEP = new IPEndPoint(ipAddress,remotePort);
Socket mySocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp );
try {
mySocket.Connect(remoteEP);
print("Socket connected to" + mySocket.RemoteEndPoint.ToString());
byte[] msg = Encoding.ASCII.GetBytes("This is a test<EOF>");
int bytesSent = mySocket.Send(msg);
int bytesRec = mySocket.Receive(bytes);
print("Echoed test = " + Encoding.ASCII.GetString(bytes,0,bytesRec));
mySocket.Shutdown(SocketShutdown.Both);
mySocket.Close();
}
catch (ArgumentNullException ane) {
print("ArgumentNullException : " + ane.ToString());
}
catch (SocketException se) {
print("SocketException : " + se.ToString());
}
catch (Exception e) {
print("Unexpected exception : " + e.ToString());
}
}
catch (Exception e) {
Console.WriteLine( e.ToString());
}
}
source
share