Ver Mensaje Individual
  #1  
Antiguo 28-02-2015
JuanOrtega JuanOrtega is offline
Miembro
NULL
 
Registrado: sep 2011
Posts: 130
Reputación: 13
JuanOrtega Va por buen camino
Problema de conexion con Sockets

Hola estoy haciendo un chat en una aplicacion de consola en delphi y tengo un problema con el siguiente codigo :

Código Delphi [-]
program chat;

{$APPTYPE CONSOLE}
{$R *.res}

uses
  System.SysUtils, System.Win.ScktComp, idContext, idGlobal;

var
  ClientSocket1: TClientSocket;
  m: TMethod;

Procedure leer_datos(Sender: TObject; Socket: TCustomWinSocket);
Var
  Raw: String;
Begin
  Raw := Socket.ReceiveText;
  Writeln(Raw);
End;

begin
  try

    ClientSocket1 := TClientSocket.Create(nil);
    ClientSocket1.Address := '127.0.0.1';
    ClientSocket1.Port := 123;
    ClientSocket1.Open;

    m.Code := @leer_datos;
    m.Data := ClientSocket1;
    ClientSocket1.OnRead := TSocketNotifyEvent(m);

    while '1'='1' do
    begin
      //
    end;


except
  on E: Exception do
    Writeln(E.ClassName, ': ', E.Message);
end;

end.

El problema es que el evento para leer el codigo de respuesta del servidor nunca llega , parece que hice mal el evento OnRead en la aplicacion de consola.

¿ Cual es el problema ?

Última edición por JuanOrtega fecha: 28-02-2015 a las 21:16:17.
Responder Con Cita