瀏覽代碼

* Fix localport detection. Fixes issue #36849

Michaël Van Canneyt 3 小時之前
父節點
當前提交
4684e4c57e
共有 1 個文件被更改,包括 7 次插入1 次删除
  1. 7 1
      utils/fppkg/lnet/lnet.pp

+ 7 - 1
utils/fppkg/lnet/lnet.pp

@@ -801,8 +801,14 @@ begin
 end;
 
 function TLSocket.GetLocalPort: Word;
+var
+  a: TSockAddr;
+  l: Integer;
 begin
-  Result := ntohs(FAddress.IPv4.sin_port);
+  Result := 0;
+  l := SizeOf(a);
+  if fpGetSockName(FHandle, @a, @l) = 0 then
+    Result := ntohs(a.sin_port);
 end;
 
 function TLSocket.GetPeerPort: Word;