diff --git a/shadowsocks-csharp/Controller/Service/UDPRelay.cs b/shadowsocks-csharp/Controller/Service/UDPRelay.cs index 47a3c6cf..5367e29a 100644 --- a/shadowsocks-csharp/Controller/Service/UDPRelay.cs +++ b/shadowsocks-csharp/Controller/Service/UDPRelay.cs @@ -40,10 +40,10 @@ namespace Shadowsocks.Controller if (handler == null) { handler = new UDPHandler(socket, _controller.GetAServer(IStrategyCallerType.UDP, remoteEndPoint, null/*TODO: fix this*/), remoteEndPoint); + handler.Receive(); _cache.add(remoteEndPoint, handler); } handler.Send(firstPacket, length); - handler.Receive(); return true; } @@ -74,6 +74,7 @@ namespace Shadowsocks.Controller } _remoteEndPoint = new IPEndPoint(ipAddress, server.server_port); _remote = new Socket(_remoteEndPoint.AddressFamily, SocketType.Dgram, ProtocolType.Udp); + _remote.Bind(new IPEndPoint(IPAddress.Any, 0)); } public void Send(byte[] data, int length)