function GetIPAddress: string; var phoste: PHostEnt; Buffer: array[0..100] of char; WSAData: TWSADATA; begin result := ''; if WSASTartup($0101, WSAData) <> 0 then exit; GetHostName(Buffer, Sizeof(Buffer)); phoste := GetHostByName(buffer); if phoste = nil then begin exit; end else result := StrPas(inet_ntoa(PInAddr(phoste^.h_addr_list^)^)); WSACleanup; end;这是取得本机的ip地址
但是 我的ABinding.peerPort却不是这个值 每次的连结他都有可能不同
为什么?
:(
而且 我两端的default port都设成了一个固定值
但是 我的ABinding.peerPort却不是这个值 每次的连结他都有可能不同
为什么?
var
phoste: PHostEnt;
Buffer: array[0..100] of char;
WSAData: TWSADATA;
begin
result := '';
if WSASTartup($0101, WSAData) <> 0 then exit;
GetHostName(Buffer, Sizeof(Buffer));
phoste := GetHostByName(buffer);
if phoste = nil then
begin
exit;
end
else
result := StrPas(inet_ntoa(PInAddr(phoste^.h_addr_list^)^));
WSACleanup;
end;这是取得本机的ip地址