Hello Everyone,
   
  I have two units -
  1)CAENUnit
  2)MainUnit
   
  There is a button "Start Server" in my main unit which when clicked starts my 
server,starts my client,thereby on session connected event the client sends 
commands to the reader to create notification channel ,receives reply on data 
available event and then the server starts receiving data from the reader
  To stop,we click on "Stop server" button in main unit which in turn stops the 
server and the client.
  My program works fine till this point.But when I restart i.e., click on start 
server again
  the server connects,client connects but the client disconnects after some 
time after sending the second command.
   
  The section of main unit which calles CAEN unit is as follows
  procedure TMainForm.StartButtonClick(Sender: TObject);
begin
  if StartButton.ImageIndex = 0 then begin
    // Starting a connection with a Reader
    try
      if ReaderComboBox.Text = 'Symbol' then begin
        SymbolForm.ClearWorkArea;
        SymbolForm.HttpServer.Start;
        SymbolForm.ServerRunning := True;
      end else if ReaderComboBox.Text = 'CAEN' then begin
        CAENForm.ClearWorkArea;
        CAENForm.StartTCPServer;
        CAENForm.Connect;
          CAENForm.ServerRunning := True;
        end;
      TestButton.Visible := True;
      ReaderComboBox.Enabled := False;
      DatabaseRepairMenu.Enabled := False;
    except
      SkinMessage.MessageDlg('Server could not be started. Please, check IP and 
Port.',mtError,[mbOk],0);
      exit;
    end;
    StartButton.ImageIndex := 1;
    StartButton.Caption := 'Stop Server';
  end else begin
    try
      if ReaderComboBox.Text = 'Symbol' then begin
        SymbolForm.HttpServer.Stop;
        SymbolForm.ServerRunning := False;
      end else if ReaderComboBox.Text = 'CAEN' then begin
        CAENForm.StopTCPServer;
        CAENForm.Close;
        CAENForm.ServerRunning := False;
      end;
      TestButton.Visible := False;
      TestButton.ImageIndex := 3;
      TestButton.Caption := 'Start Testing';
      ReaderComboBox.Enabled := True;
      DatabaseRepairMenu.Enabled := True;
    except
      SkinMessage.MessageDlg('Server could not be stopped.',mtError,[mbOk],0);
      exit;
    end;
    StartButton.ImageIndex := 0;
    StartButton.Caption := 'Start Server';
  end;
end;
   
  I am attaching the code of CAEN unit.
  Please suggest why does my client socket get disconnected after sending the 
second command .i have no clue about it...
  Please help.
  Thanks
   
   

                
---------------------------------
Do you Yahoo!?
 Next-gen email? Have it all with the  all-new Yahoo! Mail Beta.
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to