How to use IPv6 protocol in Delphi program for iOS

江枫思渺然 提交于 2019-12-12 16:43:47

问题


I try to use IPv6 protocol in my mobile program.

My server is located inside the LAN behind NAT.

On the server I use IP port 3000

I have organized Virtual Server / Port Forwarding from my router port 45500 to port 3000 of my server.

On the server, I ran the ipconfig command and got IpV6 address.

Connection-specific DNS Suffix  . :
   IPv6 Address. . . . . . . . . . . : 2a02:2168:xxxxxxx.63b1:6e81:399c
   Link-local IPv6 Address . . . . . : fe80::7c7b:xxxxxxxx399c%12
   IPv4 Address. . . . . . . . . . . : 192.168.1.100
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : fe80::e23fxxxxxxxxxcccc%12
                                       192.168.1.1

Next, I made changes to the connection library kmbmw:

FSocket.Host := FHost;
FSocket.Port := FPort;

...

{$IFDEF KBMMW_USING_INDY_10}

// Changes
//ShowMessage('Indy 10');
FSocket.ReadTimeout:=RequestTimeout*1000;
FSocket.ConnectTimeout:=ConnectTimeout*1000;

if GStack.IsIP(FHost) then // only checks for IPv4 right now
begin
  FSocket.IPVersion := Id_IPv4;
  FSocket.Connect;
end
else if MakeCanonicalIPv6Address(FHost) <> '' then
begin
  FSocket.IPVersion := Id_IPv6;
  FSocket.Connect;
end
else
begin
  // connecting to a hostname, try IPv6 first, then fallback to IPv4...
  try
    FSocket.IPVersion := Id_IPv6;
    FSocket.Host := '2a02:2168:xxxxxxx.63b1:6e81:399c'; // My IpV6 from ipconfig
    FSocket.Port := 3000;
    FSocket.Connect;
  except
    FSocket.IPVersion := Id_IPv4;
    FSocket.Host := '95.84.x.x'; // My static ipv4
    FSocket.Port := 45500;
    FSocket.Connect;
  end;
end;

// Changes

{$ENDIF}

Are these the right steps?

来源:https://stackoverflow.com/questions/43399659/how-to-use-ipv6-protocol-in-delphi-program-for-ios

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!