Hey all,
Unity3d is freezing while using sockets. It connects properly, because I see the message sent on the server, but it freezes until I end the server process (which is on another computer).
Probably a socket blocking thing?
Thanks, Christian
Hey all,
Unity3d is freezing while using sockets. It connects properly, because I see the message sent on the server, but it freezes until I end the server process (which is on another computer).
Probably a socket blocking thing?
Thanks, Christian
There could be a bug with async sockets - try using sync sockets.
Your problem is the use of StreamReader. I’ve had this issue before, and basically what is happening is that even if the stream is flushed on the sending peer, StreamReader on the receiving peer buffers data internally and does not present it to you until a sufficient amount of data is received on the stream, or you close the socket (effectively closing the stream).
Flushing the sending stream, using TCP nonagle, will not work around this because the problem is not at the socket level, it is in StreamReader itself.
The hacky way around this is to push a bunch of data through the stream to force it out on the receiving end, you can use this technique to validate the premise of your problem, but this isn’t a good solution in the long run. Consider managing your own send and receive buffers, if you require immediate delivery of data you might even want to consider switching to UDP entirely.
Could someone please help :/
– anon97051129Have you found out an answer? I still have the same problem! thanks!
– BjoernS