Hello. I'm trying to make TWSocketServer pworking in a separate thread to make 
sure it will not interfere with main application thread i would like to use 
onli for GUI
so Code sample is below

unit ServerThread;

interface

uses
  Classes, SysUtils, OverbyteIcsWSocket, OverbyteIcsWSocketS, SharedGlobals;


type
  TServerThread = class(TThread)
  private
    { Private declarations }
  protected
    procedure Execute; override;
  end;

  TTcpSrvClient = class(TWSocketClient)
  public
    RcvdLine    : String;
    ConnectTime : TDateTime;
  end;

 TServer = class(TObject)
    WSocketServerDyn: TWSocketServer;
  private
    procedure WSocketServerDynClientConnect(Sender: TObject; Client: 
TWSocketClient; Error: Word);
    procedure WSocketServerDynClientDisconnect(Sender: TObject; Client: 
TWSocketClient; Error: Word);
    procedure WSocketServerDynBgException(Sender: TObject; E: Exception; var 
CanClose: Boolean);
    constructor Create;
  public
  end;

implementation


var
  ServerSocket : TServer;

{...Skipped Events....}

constructor TServer.Create;
begin
 inherited Create;
    WSocketServerDyn                    := TWSocketServer.Create(nil);
    WSocketServerDyn.Proto       := 'tcp';         { Use TCP protocol  }
    WSocketServerDyn.Port        := '7777';      { Use telnet port   }
    WSocketServerDyn.Addr        := '0.0.0.0';     { Use any interface }
    WSocketServerDyn.ClientClass := TTcpSrvClient; { Use our component }
    WSocketServerDyn.OnClientConnect := WSocketServerDynClientConnect;
    WSocketServerDyn.OnClientDisconnect    := WSocketServerDynClientDisconnect;
    WSocketServerDyn.OnBgException    := WSocketServerDynBgException;
end;

procedure TServerThread.Execute;
begin
  ServerSocket := TServer.Create;
   try
     ServerSocket.WSocketServerDyn.Listen;
    except
        on E:Exception do begin
//            Display('Unabled to connect: ' + E.ClassName + ': ' + E.Message);
        end;
    end;
end;

end.

Whis code works. 
 ServerSocket.WSocketServerDyn.Listen;
Start listening the port and i can connecto it, but this events
    WSocketServerDyn.OnClientConnect := WSocketServerDynClientConnect;
    WSocketServerDyn.OnClientDisconnect    := WSocketServerDynClientDisconnect;
    WSocketServerDyn.OnBgException    := WSocketServerDynBgException;
Dont work. Nothing happens on connection or disconnection
Please advise.




-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to