Ver Mensaje Individual
  #6  
Antiguo 02-09-2007
FFe_ FFe_ is offline
Registrado
 
Registrado: ago 2007
Posts: 8
Reputación: 0
FFe_ Va por buen camino
Thumbs up

Gracias Dec, lo que dices es cierto. muy buena observación ;
aquí encontré una página en borland que trata sobre las diferencias entre indy 9 e indy 10:

http://bdn1.borland.com/borcon2004/a...,32160,00.html

a mí me sirvió para comprender un par de cosas... quizás a otros también.
con lo que lei aquí, hice mi primer servidor. que es muy tonto en realidad pero aún así...
Código Delphi [-]
unit server;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,IdBaseComponent, IdComponent, IdCustomTCPServer, IdTCPServer, idcontext, StdCtrls; type TForm1 = class(TForm)
    server: TIdTCPServer;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure IndyConnect(AContext: TIdContext);
    procedure serverExecute(AContext: TIdContext);
    procedure Button1Click(Sender: TObject);
  private     
{ Private declarations }   
public     
{ Public declarations }   
end;

var   Form1: TForm1;  

implementation  {$R *.dfm}  

procedure TForm1.IndyConnect(AContext: TIdContext);
// cuando se produce una conexión, enviar el mensaje 'hola....'
begin          
acontext.Connection.IOHandler.WriteLn('Hola!!!! estás conectado');
end;

procedure TForm1.serverExecute(AContext: TIdContext);
//cuando llega información al servidor, si esta es igual a 'hola' responder...
var text: string;
begin       
     with acontext.Connection.IOHandler do begin           
           text:= readln;           
           if sametext (text, 'hola')
              then                
                  begin                   
                     text:= 'hola.¿que tal?';
                     writeln (text);
                  end;
      end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin //setea el puerto de escucha del servidor y lo abre(escucha)
     server.DefaultPort:=10300;      
     server.active:= true;  end;

end.
lo probe haciendo un telnet al puerto 10300 de 127.0.0.1, aparentemente funciona, pero no me muestra el mensaje 'hola estas conectado' . porque puede ser esto? es por el telnet?
Responder Con Cita