If Bind(fdhandlein,inaddrtempx,inaddrtempsize)<> {$ifdef win32}0{$else}true{$endif} Then begin\r
state := wsclosed;\r
lasterror := {$ifdef win32}getlasterror{$else}socketerror{$endif};\r
- raise ESocketException.create('unable to bind, error '+inttostr(lasterror));\r
+ raise ESocketException.create('unable to bind on address '+localaddr+'#'+localport+', error '+inttostr(lasterror));\r
end;\r
state := wsbound;\r
end;\r
\r
function tlsocket.receivefrom(data:pointer;len:integer;var src:TInetSockAddrV;var srclen:integer):integer;\r
var\r
- srcx : {$ifdef win32}winsock.TSockAddr{$else}TInetSockAddrV{$endif} absolute src;\r
+ tempsrc:TInetSockAddrV;\r
+ tempsrclen:integer;\r
+ srcx : {$ifdef win32}winsock.TSockAddr{$else}TInetSockAddrV{$endif} absolute tempsrc;\r
+ biniptemp:tbinip;\r
begin\r
{$ifdef secondlistener}\r
if assigned(secondlistener) then if lastsessionfromsecond then begin\r
exit;\r
end;\r
{$endif}\r
- result := {$ifdef win32}winsock{$else}sockets{$endif}.recvfrom(self.fdhandlein,data^,len,0,srcx,srclen);\r
+ tempsrclen := sizeof(tempsrc);\r
+ result := {$ifdef win32}winsock{$else}sockets{$endif}.recvfrom(self.fdhandlein,data^,len,0,srcx,tempsrclen);\r
+\r
+ {$ifdef ipv6}\r
+ biniptemp := inaddrvtobinip(tempsrc);\r
+ if needconverttov4(biniptemp) then begin\r
+ converttov4(biniptemp);\r
+ tempsrclen := makeinaddrv(biniptemp,inttostr(ntohs(tempsrc.InAddr.port)),tempsrc);\r
+ end;\r
+ {$endif}\r
+\r
+ move(tempsrc,src,srclen);\r
+ srclen := tempsrclen;\r
end;\r
\r
procedure tlsocket.connectionfailedhandler(error:word);\r
{$else}\r
sockets.getsocketname(self.fdhandlein,addr,i);\r
{$endif}\r
- binip.family := addr.inaddr.family;\r
- {$ifdef ipv6}\r
- if addr.inaddr6.sin6_family = AF_INET6 then begin\r
- binip.ip6 := addr.inaddr6.sin6_addr;\r
- end else\r
- {$endif}\r
- begin\r
- binip.ip := addr.inaddr.addr;\r
- end;\r
+ binip := inaddrvtobinip(addr);\r
converttov4(binip);\r
end;\r
\r
sockets.getpeername(self.fdhandlein,addr,i);\r
{$endif}\r
\r
- binip.family := addr.inaddr.family;\r
- {$ifdef ipv6}\r
- if addr.inaddr6.sin6_family = AF_INET6 then begin\r
- binip.ip6 := addr.inaddr6.sin6_addr;\r
- end else\r
- {$endif}\r
- begin\r
- binip.ip := addr.inaddr.addr;\r
- end;\r
+ binip := inaddrvtobinip(addr);\r
converttov4(binip);\r
end;\r
\r
result := winsock.recv(fd,buf,size,0);\r
end;\r
{$endif}\r
-
+\r
end.\r
\r