我有一个三层构架的程序,采用SOCKET连接方式,主要功能是客户端远程向中心服务器上传数据.在局域网中通过公网IP地址访问应用服务器上传数据,一切正常.但发布到客户那里运行,有时一开始就程序没响应,有时候上传部分就程序没响应.ScktSrvr.exe显示一直处在连接状态中.最初我以为是服务器没响应,于是启运另一客户那里的上传程序,又能上传,只是上传部分之后没响应.我用与服务器同在一局域网中的另一台电脑上传,能正常执行完成.不知道这现象是何故?百思不得其解.上传程序中都是通过调用存储过程实现的.这问题在其他几个三层程序都有不同程度的出现,为了能彻底解决这个问题,我贴些代码供参考.如果还需要其他的资料,请跟贴,我会再贴上.客户端代码:
procedure TForm1.ExecOther;
var
  i:integer;
begin
  Try
    cdsDelStandardOther.Close;
    cdsDelStandardOther.Params.ParamByName('@KidCode').AsString:=Trim(SchoolCode);
    cdsDelStandardOther.Execute;
    cdsDelStandardOther.Active:=False;    label1.Caption:='系统正在上传 [其他收费标准数据] ...';
    with gycx1 do
    begin
      Sql.Clear;
      Sql.Add('select * from standard_other');
      Close;
      Open;
      If Eof=False Then
      Begin
        For i:=1 to RecordCount do
        Begin
          Application.ProcessMessages;
          cdsStandardOther.Close;
          cdsStandardOther.Params.ParamByName('@KidCode').AsString:=SchoolCode;
          cdsStandardOther.Params.ParamByName('@Name').AsString:=Fieldbyname('ClassName').AsString;
          cdsStandardOther.Execute;
          cdsStandardOther.Active:=False;
          Next;
        End;
      End;
      Close;
    end;    //--------------------------------------------------------------------------
    label1.Caption:='远程服务器正在处理中 ...';
    _cdsStandardOther.Close;
    _cdsStandardOther.Params.ParamByName('@KidCode').AsString:=Trim(SchoolCode);
    _cdsStandardOther.Execute;
    _cdsStandardOther.Active:=False;  Except
    on e:Exception do
    begin
      memo1.Lines.Add(Formatdatetime('hh:mm:ss',time)+' 意外错误。');
      memo1.lines.add('原因:'+e.Message);
    end;
  End;
end;