egametang 嗯,感谢大佬的回复,前面开始测的时候也是没有设置SetSocketOption的,但是服务器端会报另一个错误。
(RouterComponentSystem.cs:79) System.ArgumentException: The supplied EndPoint of AddressFamily InterNetwork is not valid for this Socket, use InterNetworkV6 instead. (Parameter ‘remoteEP’)
at System.Net.Sockets.Socket.ValidateReceiveFromEndpointAndState(EndPoint remoteEndPoint, String remoteEndPointArgumentName)
at System.Net.Sockets.Socket.ReceiveFrom(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, EndPoint& remoteEP)
at System.Net.Sockets.Socket.ReceiveFrom(Byte[] buffer, EndPoint& remoteEP)
at ET.UdpTransport.Recv(Byte[] buffer, EndPoint& endPoint)
后来设置了SetSocketOption,这个错误没有报了,最后客户端这边出错了,目前还没有头绪。从这些错误来看,像是我的客户端是ipv4的,但是调试也看了AddressFamily是AddressFamily.InterNetworkV6的。