private void BindUsingDelegate(Socket socket, IPEndPoint remoteIPEndPoint) { IPEndPoint remoteEndPoint = new IPEndPoint(remoteIPEndPoint.Address, remoteIPEndPoint.Port); int retryCount = 0; while (retryCount < 0x7fffffff) { IPEndPoint localEP = this.BindIPEndPointDelegate(this, remoteEndPoint, retryCount); if (localEP == null) { break; } try { socket.InternalBind(localEP); break; } catch { } retryCount++; } if (retryCount == 0x7fffffff) { throw new OverflowException("Reached maximum number of BindIPEndPointDelegate retries"); } }
private void BindUsingDelegate(Socket socket, IPEndPoint remoteIPEndPoint) { IPEndPoint clonedRemoteIPEndPoint = new IPEndPoint(remoteIPEndPoint.Address, remoteIPEndPoint.Port); int retryCount; for (retryCount=0; retryCount<int.MaxValue; retryCount++) { IPEndPoint localIPEndPoint = BindIPEndPointDelegate(this, clonedRemoteIPEndPoint, retryCount); if (localIPEndPoint == null) break; try { socket.InternalBind(localIPEndPoint); } catch { continue; } break; } if (retryCount == int.MaxValue) throw new OverflowException("Reached maximum number of BindIPEndPointDelegate retries"); }