最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - Unity receiving UDP packets does not work - Stack Overflow

programmeradmin7浏览0评论

I am trying to create an autorative game server that communicates with UDP (C#, running in VSCode), and a game client (Unity).

The game server sends and receives packets just fine (checked with WireShark), and the client also sends packets as it should, but the problem begins when trying to receive packets in the unity client. I have tried two implementations, and for each a different thing happens - but both do not work as they should.

Blocking UDPClient.receive() (In the main thread and in a different one) → Straight up does not work. Non Blocking UDPClient.BeginReceive(callback) → Weird thing happens, I set a l log to print when ever a packet is received. Logs only start to appear after I stop the unity editor.

More information - I checked with WireShark and packets are sent properly. I checked the firewall and enabled unity inbound rules, also tried with firewall turned off (even though I am running both on localhost? so not sure if its needed) Has anyone encountered this problem? how do I solve it?

发布评论

评论列表(0)

  1. 暂无评论