View Issue Details

IDProjectCategoryView StatusLast Update
0036849FPCPackagespublic2020-03-31 16:58
Reportergreenfil Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Platformx64OSdebian 
Summary0036849: lnet localport incorrect
DescriptionWhen using "connect" local port I can't determine the local port
Steps To Reproduceprogram Project1;

uses lNet, Sockets;

function GetLocalPort(Socket:TLSocket): Word;
var
  a: TSockAddr;
  l: Integer;
begin
  Result := 0;
  l := SizeOf(a);
  if fpGetSockName(Socket.Handle, @a, @l) = 0 then
    Result := NToHs(a.sin_port);
end;


var UDP:TLUdp;

  const Port=7080; {any}

begin
  UDP:=TLUdp.Create(nil);
  UDP.Connect('127.0.0.1', Port);
  UDP.SendMessage('Test'); //My detect local port doesn't work without Send
  WriteLn(UDP.Iterator.LocalPort); //write Port - it is incorrect
  WriteLn(GetLocalPort(UDP.Iterator)); //Write correct local port
  UDP.Free;
end.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Activities

Bart Broersma

2020-03-30 20:28

reporter   ~0121776

Both lnet and sockets are fpc.
Moving...

Marco van de Voort

2020-03-31 16:56

manager   ~0121804

Last edited: 2020-03-31 16:58

View 2 revisions

(Lnet is not part of the FPC distribution. It is part of fppkg, but not installed for enduser usage)

I tried to test (on Windows), and the output is:

7080
50950
)

Issue History

Date Modified Username Field Change
2020-03-30 08:38 greenfil New Issue
2020-03-30 20:28 Bart Broersma Note Added: 0121776
2020-03-30 20:29 Bart Broersma Project Packages => FPC
2020-03-31 16:56 Marco van de Voort Note Added: 0121804
2020-03-31 16:58 Marco van de Voort Note Edited: 0121804 View Revisions