Getting “system.net.sockets.socketexception no such host is known” in Unity WebGL build

后端 未结 2 1828
南笙
南笙 2021-01-21 11:08

Hello and thank you for taking the time to look help me with my problem.

I have been working on a small webgl thing within Unity that will send the user an email after t

相关标签:
2条回答
  • 2021-01-21 11:35

    You cannot use Sockets or any other .Net network class on WebGL. This is for security reasons. Although, you can use Unity's WWW class.

    You still have two Other Options.

    [EASY]

    1. Re-write the code you have in your question in php. Use Unity WWW class to send message(toEmail, Subject, Body) to the php script. The php script will then send the actually email with the information it received from the Unity App.

    If you don't want to learn php,you can compile the code in your question as a console app and then use it as cgi instead of php. WWW class can communicate with both php or cgi programs through GET or POST request.

    [HARD]

    2. You can implement smtp protocol or your own MailMessage class with UnitySocketIO library. https://github.com/NetEase/UnitySocketIO

    0 讨论(0)
  • 2021-01-21 11:39

    Due to security implications, JavaScript code does not have direct access to IP Sockets to implement network connectivity. As a result, the .NET networking classes (ie, everything in the System.Net namespace, particularly System.Net.Sockets) are non-functional in WebGL.

    According to unity Doc http://docs.unity3d.com/Manual/webgl-networking.html

    Hence the Error.

    0 讨论(0)
提交回复
热议问题