Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2004.07.25;
Скачать: CL | DM;

Вниз

Winsock: Помогите получить адреса из списка   Найти похожие ветки 

 
Micah'GF   (2004-05-30 11:04) [0]

Есть такая структура:
 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.
Как правильно сделать?


 
Verg ©   (2004-05-30 12:12) [1]


var Adr : ^PInAddr;
    Ph  : PHostEnt;
............
   Adr := pointer(Ph.h_addr_list);
   while Adr^ <> nil do
   begin
     Writeln(inet_ntoa(Adr^^));
     inc(Adr);
   end;


 
Micah'GF   (2004-05-30 21:17) [2]

спасибо.. помогло:
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;



Страницы: 1 вся ветка

Текущий архив: 2004.07.25;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.049 c
1-1089357876
cvg
2004-07-09 11:24
2004.07.25
почему нет STEP в цикле FOR???


3-1088473351
bigfoot
2004-06-29 05:42
2004.07.25
DBGrid + XML


14-1089287372
Igorek
2004-07-08 15:49
2004.07.25
LMD or not LMD? - that is the question


3-1089002851
Jiny
2004-07-05 08:47
2004.07.25
IB manager problem


14-1089177548
Ega23
2004-07-07 09:19
2004.07.25
Ещё раз к вопросу о драйверах