From 46424de88e9de51a8151fd6ef813ff7827b1ad8c Mon Sep 17 00:00:00 2001 From: beware Date: Wed, 10 Feb 2010 03:34:48 +0000 Subject: [PATCH] getsockname fixes. getXaddr was returning peer addr git-svn-id: file:///svnroot/lcore/trunk@71 b1de8a11-f9be-4011-bde0-cc7ace90066a --- lsocket.pas | 8 ++++++-- unixstuff.inc | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lsocket.pas b/lsocket.pas index f7d40e3..af3faf8 100755 --- a/lsocket.pas +++ b/lsocket.pas @@ -177,6 +177,10 @@ end; begin result := getpeername(sock,addr,addrlen); end; + function system_getsocketname(Sock: LongInt;var Addr;var Addrlen: LongInt):LongInt; + begin + result := getsocketname(sock,addr,addrlen); + end; function system_listen(Sock: LongInt; MaxConnect: LongInt):Boolean; begin result := listen(sock,maxconnect); @@ -686,7 +690,7 @@ begin {$ifdef win32} winsock.getsockname(self.fdhandlein,psockaddr(@addr)^,i); {$else} - getsocketname(self.fdhandlein,addr,i); + system_getsocketname(self.fdhandlein,addr,i); {$endif} binip := inaddrvtobinip(addr); converttov4(binip); @@ -737,7 +741,7 @@ begin winsock.getsockname(self.fdhandlein,psockaddrin(@addr)^,i); {$else} - getsocketname(self.fdhandlein,addr,i); + system_getsocketname(self.fdhandlein,addr,i); {$endif} result := inttostr(htons(addr.InAddr.port)); diff --git a/unixstuff.inc b/unixstuff.inc index f5de6d4..0eb9b3d 100755 --- a/unixstuff.inc +++ b/unixstuff.inc @@ -81,7 +81,7 @@ end; function GetSocketName(Sock: LongInt; var Addr;var Addrlen: LongInt):LongInt; begin - result := fpgetpeername(sock,@addr,@addrlen); + result := fpgetsockname(sock,@addr,@addrlen); end; function Accept(Sock: LongInt; var Addr; var Addrlen: LongInt):LongInt; begin -- 2.30.2