X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/46424de88e9de51a8151fd6ef813ff7827b1ad8c..f8e139db970666e906db30417763f81e2ae5e801:/lsocket.pas?ds=sidebyside diff --git a/lsocket.pas b/lsocket.pas index af3faf8..c099cf5 100755 --- a/lsocket.pas +++ b/lsocket.pas @@ -177,10 +177,6 @@ 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); @@ -373,7 +369,7 @@ end; procedure tlsocket.listen; var - yes:longint; + yes,no:longint; socktype:integer; biniptemp:tbinip; origaddr:string; @@ -412,10 +408,14 @@ begin try yes := $01010101; {Copied this from existing code. Value is empiric, but works. (yes=true<>0) } + no := 0; {$ifndef win32} if SetSocketOptions(fdhandlein, SOL_SOCKET, SO_REUSEADDR,yes,sizeof(yes))=-1 then begin raise ESocketException.create('unable to set socket options'); end; + if SetSocketOptions(fdhandlein, IPPROTO_IPV6,IPV6_V6ONLY,no,sizeof(no))=-1 then begin + raise ESocketException.create('unable to set socket options'); + end; {$endif} localaddr := addr; localport := port; @@ -690,7 +690,7 @@ begin {$ifdef win32} winsock.getsockname(self.fdhandlein,psockaddr(@addr)^,i); {$else} - system_getsocketname(self.fdhandlein,addr,i); + getsocketname(self.fdhandlein,addr,i); {$endif} binip := inaddrvtobinip(addr); converttov4(binip); @@ -741,7 +741,7 @@ begin winsock.getsockname(self.fdhandlein,psockaddrin(@addr)^,i); {$else} - system_getsocketname(self.fdhandlein,addr,i); + getsocketname(self.fdhandlein,addr,i); {$endif} result := inttostr(htons(addr.InAddr.port));