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

北慕城南 提交于 2019-12-02 01:09:42

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!