- Home /
Asynchronous Sockets still have problem in 4.6.3f1 with IL2CPP
Here we just upgrade our project to 4.6.3f1 to support x64 in iOS. yet we found the network is no longer working well (only) when deployed on iOS x64.
//initial bytesData
//....
_Socket.BeginSend(bytesData, 0, bytesData.Length, SocketFlags.None, new AsyncCallback(SocketSended), null);
The BeginSend just don't response. Neither SocketSended is called nor the server recieved the data. I've read about official logs that Asynchronous Socket is supported by IL2CPP in the 4.6.3 release, and the Socket connection works just fine(Socket.BeginConnect).
Can anyone help me out of that?
Update 3.17 : Just Locate the problem more sepecific. The none-functional code is like this below:
class tcpClient
{
public void Connect()
{
//init socket
//...
mSocket.BeginConnect(..., OnConnected, ..);
}
public void SendData(...)
{
//init bytesData
//...
mSocket.BeginSend(bytesData,..., OnSended);
}
private void OnConnected()
{
mSocket.BeginReceive(..., OnReceived, ..);//when remove this line, SendData works
SendData(...);
}
private void OnSended() { ... }
private void OnReceived() { ... }
}
However, if I removed BeginReceive line, the BeginSend works again. Further more, I've tried to switch BeginSend to Send. It also doesn't work. And Again, this situation only happened when my project is deployed on ios x64. In any other cases like ios x86/android/editor the code works just fine.
Update 3.18 :
I've created a simple client to test the .Net Asynchronous Socket interface. Turns out BeginSend and BeginReceive can work well separately. Only one can be functional when both used, the other must use the block method (eg. BeginSend + Receive/BeginReceive + Send)
We have some more fixes for this code in 4.6.3p4, please give that version a try. If the problem still exists, could you submit a bug? That will help us track it down.
hello, I use (BeginReceive + Send), but it not work, I can send data, but cannot receive data! The server can recevie my data! Can you give me some help? thank you!
@dianjiang: If you are using the latest version (4.6.3p4), and this still does not work. Please submit a bug. That will give us the best chance to correct the problem,
@dianjiang: try use ReceiveAsync to replace Begin/EndReceive, that will work for both async receive & read. @JoshPeterson The problem still exist in 4.6.4f1
Can you help me , How can you use ReceiveAsync to replace Begin/EndReceive. thank you very much.
Answer by yifei-zhang · Mar 15, 2017 at 09:18 AM
use Connect(IPAddress[] ipAddresses, int port); instead Connect(IPAddress address, int port);
I was hit by the same bug described in the question. (On Unity 5.6.4f1, XCode 9.1, with IL2CPP + arm64)
After changing the BegtinConnect
function to BeginConnect(IPAddress[], ...)
, the problem had gone away.
Your problem solved, I have the same problem, but not solved, you can help me?
Answer by zugsoft · Apr 21, 2015 at 07:40 AM
Hello, I have the same problem, my game works fine with Mono, but doesn't work with IL2CPP. I use 4.6.4f1
Please try using the latest 4.6.4 patch release. If the problem still persists, the best option is to submit a bug so that we can explore it. Thanks.
We actually have a number of IL2CPP fixes in each patch release, so you may want to try 4.6.4p3. You can find it here: http://unity3d.com/unity/qa/patch-releases
Answer by wavebbs · Nov 03, 2016 at 11:08 AM
I have the same problem, my game works fine with Mono, but doesn't work with IL2CPP. I use 5.4.2p2!!!!Thank you very much!!!