![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Winsock: Помогите получить адреса из списка [D6, WinXP]
Micah'GF © (2004-05-30 11:04:00)Есть такая структура:
hostent = record
h_name: PChar;
h_aliases: ^PChar;
h_addrtype: Smallint;
h_length: Smallint;
case Byte of
0: (h_addr_list: ^PChar);
1: (h_addr: ^PChar)
end;
Заполняю эту структуру так:
GetHostName(buf,255);
RemoteHost := GetHostByName(buf);
..h_addr_listдолжна теперь указывать на список IP-адресов.. извлекаю так:
Adress.S_addr := longint(pointer(RemoteHost^.h_addr_list^)^);
..извлекается только первый.. Пытаюсь так:
Adress.S_addr := longint(pointer(RemoteHost^.h_addr_list^[2])^);
выдает ошибку... В списке точно несколько IP -h_lengthпоказывает 4.
Как правильно сделать?
Micah'GF (2004-05-30 21:17:00) [1]спасибо.. помогло:
RemoteHost : PHostEnt;
Adress: TInAddr;
PInAdress: ^PInAddr;
...
RemoteHost := GetHostByName(buf);
PInAdress := pointer(RemoteHost^.h_addr_list^);
if PInAdress^ = NIL then
Adress.S_addr := htonl($7F000001) (* 127.0.0.1 *)
else begin
inc(PInAdress, select);
Adress.S_addr := longint(PInAdress^);
end;
Verg (2004-05-30 12:12:00) [2]
var Adr : ^PInAddr;
Ph : PHostEnt;
............
Adr := pointer(Ph.h_addr_list);
while Adr^ <> nil do
begin
Writeln(inet_ntoa(Adr^^));
inc(Adr);
end;