如题,试验成功,马上结贴

解决方案 »

  1.   

    客户端的:
    procedure TIOCPSEVER1.callback(S:tsocket;Even:integer);stdcall;
    begin
      PostMessage(FwindowHandle,wm_user+Even,s,0);
    end;
    function TIOCPSEVER1.init(callback:pointer;port:integer):longbool;
    begin
      result:=_init(pointer(self),callback,port);
    end;
    明天再贴中间层的
      

  2.   

    http://www.undu.com/Articles/991107c.html
      

  3.   

    http://bdn.borland.com/article/0,1410,25982,00.html
      

  4.   

    http://www.delphibbs.com/keylife/iblog_show.asp?xid=1107
      

  5.   

    http://www-900.ibm.com/developerWorks/cn/linux/l-callback/index.shtml
    這篇可能最好!!
      

  6.   

    我的理解是, 將 客户端 一個函數的指針(or 引用)傳給 server 端, 然後, Server端保存該指針, 然後, 在適當的時候調用!當然, 實現過程很多細節不是那麼簡單!
      

  7.   

    覺得大概關鍵詞是什麼, 就在google找!象上面的文章, 比我自己表達的, 專業了很多, 也詳細了很多!
      

  8.   

    http://community.borland.com/article/0,1410,29539,00.htmlImplementing Callbacks to a Datasnap Server InterfaceAdding the Code to the Server
    procedure TxwCallBackRDM.AssignCallback(ACallback: OleVariant);
    begin
      FClientCallback := ACallback;
    end;procedure TxwCallBackRDM.Timer1Timer(Sender: TObject);
    begin
      Timer1.Enabled := False;
      FClientCallback.CallbackMethod('This is the message.');
    end;procedure TxwCallBackRDM.RemoteDataModuleCreate(Sender: TObject);
    begin
      Timer1.Enabled := True;
    end;
    Setting up the Client
    On the client, I implemented the IClientCallback interface as the class TClientCallback within the main form's unit. The code for the main form is shown below. unit xwcMainFrm;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, CallBackSrv_TLB, DB, DBClient, MConnect, ComObj, ActiveX;type  TClientCallback = class(TAutoIntfObject, IClientCallback)
      protected
        procedure CallbackMethod(const AMessage: WideString); safecall;
      end;  TMainForm = class(TForm)
        DCOMConnection1: TDCOMConnection;
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
        FClientCallback: TClientCallback;
      public
        { Public declarations }
      end;var
      MainForm: TMainForm;implementation{$R *.dfm}{ TClientCallback }procedure TClientCallback.CallbackMethod(const AMessage: WideString);
    begin
      ShowMessage(AMessage);
    end;procedure TMainForm.FormCreate(Sender: TObject);
    var
      typelib: ITypeLib;
    begin
      DCOMConnection1.Connected:=true;
      OleCheck(LoadRegTypeLib(LIBID_CallbackSrv, 1, 0, 0, typelib));
      FClientCallback := TClientCallback.Create(typelib, IClientCallback);  DCOMConnection1.AppServer.AssignCallback(FClientCallback as IDispatch);
    end;end.自己到那個網頁看下更好!!