Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by sandalia · May 02, 2012 at 09:39 AM · servereventweb

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!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · May 02, 2012 at 11:49 AM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by sandalia · May 02, 2012 at 03:45 PM

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();
     */
      
 
      

       }
 
   }



Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How can i receive data from URL like cookies? 0 Answers

Analytic Tool: Get a list of custom user ID for core/custom events. 0 Answers

How to access StartCoroutine in a static way 3 Answers

`Recv failure: Connection was reset` In editor? (platform set to Android NOT WebPlayer) 0 Answers

Developing a server to host a smartphone app content 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges