External Server Event Unity Web

Hello,
From what I’ve read Unity Web does not allow you to use dlls for security reasons, then, is there any way for an external server (which has not been created from Unity) send some kind of event or message to the application (Unity Web) ?

In desktop app, the way I had to do this was through sockets and a customized dll, but it’s not possibloe in unity web so I’m kind of lost.

Any ideas?

Thank you very much!

You can use Sockets even in the webplayer. However the webplayer can’t act as listening socket(server) to accept connections. You can connect to an external server.

Read this page about the security sandbox very carefully. Your server needs to provide a crossdomain policy to allow access to your server. I also recommend to use TCP connections since UDP is connection-less it has to check the policy for each packet that goes out or is comming in. TCP needs to check the policy only when you open the connection.

Thank you, I’ve been checking the security sandbox, but I wonder if it is possible next: the tcp client connects to the server, and after checking the crossdomain policy, the tcp client can read the answer of the server with the Read method, I mean, what I really want is the client waiting all time for answers from the server.

I’ve tried the SocketPolicyServer located in Tools/SocketPolicyServer that Unity provides you, with the next code for the client:

using UnityEngine;
using System.Collections;
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
public class ClientTest : MonoBehaviour
{

      BinaryWriter so;
	  BinaryReader sr;
      // Use this for initialization

      void Start () {

          TcpClient client = new TcpClient();
   

          IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse("212.128.171.225"), 843);

   

          client.Connect(serverEndPoint);

   

          NetworkStream clientStream = client.GetStream();

         

          while (!clientStream.CanRead || !clientStream.CanWrite)

          {

              Debug.Log("Spinning until can write");

          }

          so = new BinaryWriter(clientStream);
      sr = new BinaryReader(clientStream);
     

          so.Write("<policy-file-request/>");

          so.Flush();

	
	//Instead of this
		Debug.Log(sr.Read());
     //We want something like (suppose the server from time to time sends to the client some data)
	/*
	 * for(;;)
	 * 	sr.Read();
	*/
     

     

      }

  }