附上客户端例子的全部代码。(非常简单)
----------------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, DBClient, MConnect, SConnect;
type
TForm1 = class(TForm)
ClientDataSet1: TClientDataSet;
SocketConnection1: TSocketConnection;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
ClientDataSet1.Close;
ClientDataSet1.CommandText:='select top 1 .....';
ClientDataSet1.Open;
end;
end.
--------------------------------------
object Form1: TForm1
Left = 192
Top = 107
Width = 696
Height = 480
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 272
Top = 288
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 0
OnClick = Button1Click
end
object ClientDataSet1: TClientDataSet
Aggregates = <>
CommandText = 'SELECT TOP 1 * FROM KUSER'
Params = <>
ProviderName = 'dspTemp'
RemoteServer = SocketConnection1
Left = 192
Top = 144
end
object SocketConnection1: TSocketConnection
Connected = True
ServerGUID = '{400A4195-44D5-4AEA-A2D9-8FA924E0F7EE}'
ServerName = 'kAppServer.TkAppServer'
Address = '69.42.46.49'
Port = 5003
Left = 240
Top = 144
end
end
--------------------------------
其中,中间层也是个空壳,没东西,我的客户端只是做一个非常简单的数据请求,
操作流程是这样:
1》。服务器上启动“中间层”,
2》。客户端上启动“客户端”,(一启动,就默认连接上了中间层,设计是就设为SocketConnection.Connected:=True
3》。服务器端断网(拔网线)
4》。客户端点击查询按纽。
5》。客户端就处于“无响应”状态。
----Delphi7是这样,但Delphi6中,虽然也会无响应,但过了几秒钟,会弹出个异常来。
我无法忍受D7中这样无止境的无响应,希望也能像D6一样出现一个异常来,这样,我就可以进下处理一下