Ver Mensaje Individual
  #3  
Antiguo 13-06-2005
JXJ JXJ is offline
Miembro
 
Registrado: abr 2005
Posts: 2.475
Reputación: 22
JXJ Va por buen camino
Buen dia,.
jachguate

Para poder, parsear la respuesta. ¿Qué evento uso?

Por que estoy tratando de adaptar., el ejemplo que encontre en el foro.

para obtener la ip real de la petición heca a un servidor.

Este es el codigo que quiero adaptar para que no use sockclient. sino el
idHTTPClient

Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ScktComp, StdCtrls;

type
  TForm1 = class(TForm)
    cs: TClientSocket;
    Label1: TLabel;
    Button1: TButton;
    Memo1: TMemo;
    procedure suitempButton1Click(Sender: TObject);
    procedure csRead(Sender: TObject; Socket: TCustomWinSocket);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
   str :  string;
   posIp : integer;
   posFin : integer;
   ip : string;
implementation

{$R *.dfm}

procedure TForm1.suitempButton1Click(Sender: TObject);
begin
with cs do begin
      Socket.SendText('GET http://dynamic.zoneedit.com/checkip.html HTTP/1.0'+#13#10);
      Socket.sendText('Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/msword, application/vnd.ms-excel, */*'+#13#10);
      Socket.SendText('Referer: http://www.zoneedit.com/'+#13#10);
      Socket.sendText('User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)'+#13#10);
      Socket.SendText('Host: www.zoneedit.com'+#13#10);
      Socket.sendText('Content-Length: 0'+#13#10);
      Socket.sendText(''+#13#10);
      Socket.sendText(''+#13#10);
   end;

end;

procedure TForm1.csRead(Sender: TObject; Socket: TCustomWinSocket);
begin
   str := cs.Socket.ReceiveText;
   posIp := pos('Current IP Address:', str);
   posFin := pos('
Hostname'
, str); ip := copy(str, posIp + 20, posFin - (posIp + 22)); begin Memo1.Text := ip; end; end; end. {Fin del codigo}

VAle gracias.
Responder Con Cita